同图片的二进制转换雷同。就是在页面上多加了显示视频控件的代码.

详细内容可参照http://blog.csdn.net/qbb3050466/archive/2009/02/11/3876421.aspx

我的简单代码如下:

aspx 中:

    <object >
     <param name="FileName" value="<% =sval %>"/>
     <param name="AutoStart" value="-1"/>
     <param name="ShowDisplay" value="0"/>
   </object>

 

aspx.cs 中:

    public string sval;
    string strpath;
    protected void Page_Load(object sender, EventArgs e)
    {
        strpath = HttpContext.Current.Request.PhysicalApplicationPath + "1.avi";       
    }

    public byte[] getBytes(string filePath)//视频文件转换成二进制
    {
        System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open);
        byte[] videoData = new byte[fs.Length];
        fs.Read(videoData, 0, (int)fs.Length);
        return videoData;
    }

    protected void Button1_Click(object sender, EventArgs e)//单击按钮。页面显示该视频
    {

        byte[] bvideo = getBytes(strpath);
        //将二进制转换后存成2.avi
        string strPath = "2.avi";
        string strPhotoPath = Server.MapPath(strPath);

        BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath, FileMode.OpenOrCreate));
        bw.Write(bvideo);
        bw.Close();
        sval = HttpContext.Current.Request.PhysicalApplicationPath + strPath;
    }

相关文章:

  • 2021-08-03
  • 2021-06-14
猜你喜欢
  • 2022-02-04
  • 2021-12-02
  • 2021-08-20
  • 2021-07-05
  • 2021-11-22
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案