同图片的二进制转换雷同。就是在页面上多加了显示视频控件的代码.
详细内容可参照http://blog.csdn.net/qbb3050466/archive/2009/02/11/3876421.aspx
我的简单代码如下:
aspx 中:
<object id="nsPlayer" classid="clsid:05589FA1-C356-11CE-BF01-00AA0055595A" width="500" height="500">
<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;
}