How to display video file from database

I

Isabella

I have successfully insert .wmv files into MySQL. When I display the video
in the browser using Read.aspx to get the .wmv:

Response.ContentType = objDataReader.Item("swingContentType")
Response.BinaryWrite(objDataReader.Item("swing"))

if I directly call this Read.aspx, window media will open and play the .wmv.
But I want to play the .wmv in browser, so I use another file to display
..wmv with <object>. Nothing happen:

<OBJECT id="player" type="application/x-oleobject" height="280" width="400"
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" VIEWASTEXT>
<PARAM NAME="Filename" VALUE="Read.aspx">
</OBJECT>


Any ideas?



Isabella
 
I

Isabella

I found that it works if upgrade to windows media 9 and Acelp.Net Audio
Codec is asked to installed.
From msdn web site, "Sipro Labs ACELPR .net audio codec is a version of the
Algebraic-Code-Excited Linear Prediction (ACELP) compression methodologies
that has been optimized for use on Internet Protocol (IP) networks and the
Intel Pentium platform. Using the ACELP net-adapted packetization method, it
is able to minimize the impact of errors and significantly improve the error
correction possibilities in case of data-packet loss. This codec uses frame
concatenation and interlacing to more efficiently encode data. In Windows
Media Encoder, ACELP.net can be used to compress audio to bandwidths ranging
from 5 Kbps to 16 Kbps. This codec is most useful for encoding low bit rate
voice content.
After content has been sufficiently compressed, the data must be formatted
so that it can be easily streamed over a network. To create Windows Media
content for streaming, or downloading as a .wma file, the content is encoded
in ASF."

Anyone know what happen. How can I fix it if users don't have window media
9?

Thanks

Isabella
 
Joined
Feb 14, 2008
Messages
1
Reaction score
0
Hello

Did you manage to view or display the video in the browser?

If you did then please show us your script so that we can have the idea.

Actually, we are trying to do the same thing, but unfortunatelly we are stack!

Thanks
Harib
 
Joined
Oct 8, 2009
Messages
4
Reaction score
0
I used Silverlight Mediaplayer

1.Create Database table with following attributes:
vid int,video varbinary(max),v_name varchar(50),v_size Bigint
2.create aspx page with following controls
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField HeaderText="Video">
<ItemTemplate>
<asp:MediaPlayer ID="MediaPlayer1" runat="server" Height="154px" Width="224px"
MediaSource='<%# "VideoHandler.ashx?id=" + Eval("vid") %>' AutoPlay="false" >
</asp:MediaPlayer>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Silverlight ID="Silverlight1" runat="server" Height="100px" Width="100px">
</asp:Silverlight>
3.Write following code in Default2.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
String cs = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(cs);
sqlconn.Open();
string query = "SELECT * FROM Video";
SqlDataAdapter da = new SqlDataAdapter(query, sqlconn);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}

4.Create GenericHandler (from add new item) and name it as VideoHandler.ashx (mentioned in aspx page of step 2)
public void ProcessRequest (HttpContext context) {
String cs = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("SELECT video" +
" FROM Video WHERE vid = @id", sqlconn);
cmd.Parameters.Add("@id", SqlDbType.Int).Value =
context.Request.QueryString["id"];
try
{
sqlconn.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default);
if (reader.HasRows)
{
while (reader.Read())
{
context.Response.Buffer = true;
context.Response.Charset = "";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.ContentType = "video/x-ms-wmv";
context.Response.BinaryWrite((byte[])reader["Video"]);
context.Response.End();
}
}
reader.Close();
reader.Dispose();
}
finally
{
sqlconn.Close();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top