在网页上嵌套视频

我在网上找了一些代码,根据自己的需要现在写了这个类,现在发出来,希望能帮助大家.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

using System.Text;

/// <summary>
/// video 的摘要说明
/// </summary>
public class video
{
 

 public video()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }
    /// <summary>
    /// 弹出播放器
    /// </summary>
    /// <param name="sql"></param>
    /// <param name="conn"></param>
    public static void videoi(string sql,SqlConnection conn)
    {

        StreamWriter srd = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("Video/list.m3u"), false, System.Text.Encoding.GetEncoding("gb2312"));
        srd.Write("http://" + HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"] + "/Video/" + filmName(sql, conn) + "/n/r");
        srd.Close();     
    }
    public static string filmName(string sql,SqlConnection conn)
    {
        conn.Open();
        SqlCommand scd = new SqlCommand(sql, conn);
        string strFilmPath = Convert.ToString(scd.ExecuteScalar());
        conn.Close();
        return strFilmPath;
    }
    /// <summary>
    ///  下载代码
    /// </summary>
    /// <param name="sql"></param>
    /// <param name="conn"></param>
    public static void down(string sql,SqlConnection conn)
    {
        string name =filmName(sql,conn);
        string filename = "Video/" + name;
        if (filename != "")
        {
            string path = System.Web.HttpContext.Current.Server.MapPath(filename);
            FileInfo file = new FileInfo(path);
            if (file.Exists)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpContext.Current.Server.UrlEncode(name));
                HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
                HttpContext.Current.Response.ContentType = "application/octet-stream; charset=gb2312";
                HttpContext.Current.Response.Filter.Close();
                HttpContext.Current.Response.WriteFile(file.FullName);
                HttpContext.Current.Response.End();
            }
        }
    }
    /// <summary>
    /// 在网页上的播放器
    /// </summary>
    /// <param name="width"></param>
    /// <param name="height"></param>
    /// <param name="url"></param>
    public static void webVideo(int width,int height,string url)
    {
        HttpContext.Current.Response.Write("<OBJECT id='WindowsMediaPlayer1' style='WIDTH:" +width+"; HEIGHT: "+height+"' classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6'>");
        HttpContext.Current.Response.Write("<PARAM NAME='URL' VALUE='"+url+"'>");
        HttpContext.Current.Response.Write("<PARAM NAME='rate' VALUE='1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='balance' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='defaultFrame' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='playCount' VALUE='1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='autoStart' VALUE='-1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='currentMarker' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='invokeURLs' VALUE='-1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='baseURL' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='volume' VALUE='50'>");
        HttpContext.Current.Response.Write("<PARAM NAME='mute' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='uiMode' VALUE='full'>");
        HttpContext.Current.Response.Write("<PARAM NAME='stretchToFit' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='windowlessVideo' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='enabled' VALUE='-1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='enableContextMenu' VALUE='-1'>");
        HttpContext.Current.Response.Write("<PARAM NAME='fullScreen' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='SAMIStyle' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='SAMILang' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='SAMIFilename' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='captioningID' VALUE=''>");
        HttpContext.Current.Response.Write("<PARAM NAME='enableErrorDialogs' VALUE='0'>");
        HttpContext.Current.Response.Write("<PARAM NAME='_cx' VALUE='11113'>");
        HttpContext.Current.Response.Write("<PARAM NAME='_cy' VALUE='7461'>");
        HttpContext.Current.Response.Write("</OBJECT>");
      
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值