Play AVI file from byte array in ASP.Net

Possible duplicate:
Is it possible to use data URIs in video and audio tags?

Is it possible to play video files that are stored in a database as easy as displaying an image from db?

To display an 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 I can use these things below without first creating a file on the server ?

 <embed src="video.avi" /> <img dynsrc="video.avi" /> <object data="video.avi" type="video/avi" /> 

How can i achieve this?

I know that Silverlight does not play .avi files, but only wmv.

+4
source share
1 answer

You can use Windows Media Player to play AVI files. Here is the 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> 

You can also use FlashPlayer.

Since you have a file in the form of a byte array (db source), you will need to create a shared handler (ashx) to transfer this file to Media Player. Then the Html parameter for FileName will look something like this:

 <PARAM NAME="FileName" VALUE="handler.ashx?file=yourFile"> 

Make sure you set the correct ContentType inside the ashx handler as follows:

 context.Response.ContentType = "video/avi"; context.Response.Write(fileData, 0, fileData.Length); 

Here is the link to get started with ashx files:

http://msdn.microsoft.com/en-us/library/bb398986(v=vs.100).aspx

+5
source

Source: https://habr.com/ru/post/1438964/


All Articles