How to display video file from database

Discussion in 'ASP .Net' started by Isabella, Nov 22, 2003.

  1. Isabella

    Isabella Guest

    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
     
    Isabella, Nov 22, 2003
    #1
    1. Advertising

  2. Isabella

    Isabella Guest

    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



    "Isabella" <> ¦b¶l¥ó
    news: ¤¤¼¶¼g...
    > 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
    >
    >
    >
     
    Isabella, Nov 22, 2003
    #2
    1. Advertising

  3. Isabella

    harib

    Joined:
    Feb 14, 2008
    Messages:
    1
    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
     
    harib, Feb 14, 2008
    #3
  4. Isabella

    gani21

    Joined:
    Oct 8, 2009
    Messages:
    4
    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();
    }
    }
     
    gani21, Oct 20, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    2
    Views:
    2,024
    Herfried K. Wagner [MVP]
    Sep 11, 2003
  2. =?Utf-8?B?U1M=?=
    Replies:
    3
    Views:
    3,844
    Juan T. Llibre
    May 15, 2005
  3. Replies:
    3
    Views:
    475
    Travis Newbury
    Feb 8, 2006
  4. wallge
    Replies:
    8
    Views:
    702
    wallge
    Jan 12, 2007
  5. David Buckley

    req converting video to flash video examples

    David Buckley, Apr 22, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Peter Bromberg [C# MVP]
    Apr 22, 2008
Loading...

Share This Page