Play AVI file from byte array in ASP.Net
asp.net, c#
Solution
You can use windows media player for playing avi files. Here is html code:
<OBJECT ID="MediaPlayer" WIDTH="320" HEIGHT="160" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject">
<PARAM NAME="FileName" VALUE="yourFile.avi">
<PARAM name="autostart" VALUE="false">
<PARAM name="ShowControls" VALUE="true">
<param name="ShowStatusBar" value="false">
<PARAM name="ShowDisplay" VALUE="false">
<EMBED TYPE="application/x-mplayer2" SRC="yourFile.avi" NAME="MediaPlayer"
WIDTH="320" HEIGHT="160" ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"> </EMBED>
</OBJECT>
FlashPlayer can be used also.
Because you have file as byte array (db source) you will need to create generic handler (ashx) to stream this file to Media Player. Html parameter for FileName would then look something like this:
<PARAM NAME="FileName" VALUE="handler.ashx?file=yourFile">
Make sure you set correct ContentType inside ashx handler like this:
context.Response.ContentType = "video/avi";
context.Response.Write(fileData, 0, fileData.Length);
Here is link to get you started with ashx files:
http://msdn.microsoft.com/en-us/library/bb398986(v=vs.100).aspx
Problem
Possible Duplicate: Is it possible to use data URIs in video and audio tags? Is it possible to play video files which are stored in database as easy as displaying an image from db? To display a image from db, this is what I use; aspx file ``` <asp:Image ID="PicImage" runat="server" /> ``` cs file ``` PicImage.Attributes.Add("src", "data:image/png;base64," + Convert.ToBase64String(PictureByteArray)); ``` do you think, can I use these things below without creating the file in the server first? ``` <embed src="video.avi" /> <img dynsrc="video.avi" /> <object data="video.avi" type="video/avi" /> ``` How can I achieve this? I know Silverlight doesn't play .avi files, but only wmv.