Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to play video from database...?
Posted
Comments
Foothill 8-Jul-13 17:34pm    
Do you mean directly from the database? Then you can't. Databases don't store the data like that. In order to play a video from a database, first you must download the binary data, turn it back into a video file, and then you can play with any standard media player.
brighteyes24 9-Jul-13 7:55am    
do you have article for this? i have an article about this but when i play it wont work..it saves only in database...

Hi...
1st videos or images are save in folder and it's url is stored in database is better.
Now we are retriveing url only from database for palying video or images.
Ex:Videos save in folder like
C#
//Get Filename from fileupload control
                string filename = Path.GetFileName(fileupload.PostedFile.FileName);
                //Save images into Images folder
                fileupload.SaveAs(Server.MapPath("~/Images/" + filename));

Url in database:
C#
con = new MySqlConnection(cs);
                con.Open();
cmd = new MySqlCommand("Insert into Items(ProductName,ImageUrl) values(@ImageName,@ImagePath)", con);
                        //Passing parameters to query
                        cmd.Parameters.AddWithValue("@ImageName", filename);
                        cmd.Parameters.AddWithValue("@ImagePath", "~/Images/" + filename);
                        con.Open();
                        cmd.ExecuteNonQuery();
                        //Close dbconnection
                        con.Close();

so,then select ur required video with url and use ur required media player for video's.
Thank U.
 
Share this answer
 
v2
Comments
Member 10600683 16-Feb-14 12:14pm    
can you give sample projects like that ?
Hi...
For playing Video like.
XML
In .aspx:
<asp:DropDownList ID="ddlvideo" runat="server" Height="25px"
            AppendDataBoundItems="true" ForeColor="DarkOliveGreen"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="170px"
            style="font-weight: 700" AutoPostBack="True">
        </asp:DropDownList>
<asp:Label ID="ddllbl" runat="server" ></asp:Label>
<asp:literal id="Literal1" runat="server"></asp:literal>

For select Video(aspx.cs):
In FormLoad:
     con = new MySqlConnection(cs);
                con.Open();
                //Query to insert images path and name into database
                cmd1 = new MySqlCommand("select * from Videos", con);
                cmd1.ExecuteNonQuery();
                da = new MySqlDataAdapter(cmd1);
                DataSet ds = new DataSet();
                da.Fill(ds);
                con.Close();
                ddlvideo.DataSource = ds;
                ddlvideo.Items.Add("--- Select Video File ---");
                ddlvideo.DataValueField = "VideoNo";
                ddlvideo.DataTextField = "VideoName";
                ddlvideo.DataBind();
In DropDownList1_SelectedIndexChanged:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string surl = "Videos/" + ddlvideo.SelectedItem.Text;
            if (surl == "Videos/" + "--- Select Video File ---")
            {
                ddllbl.ForeColor = Color.Red;
                ddllbl.Font.Bold = true;
                ddllbl.Text = "Pls Select Video File ";
                Literal1.Visible = false;
            }
            else
            {
                bool isfullsize = false;
                this.Literal1.Text = this.getvideo(surl, isfullsize);
            }
        }  

private string getvideo(string surl, bool isfullsize)
    {
        string sobj = "";
        surl = surl + "";
        surl = surl.Trim();
        if (surl.Length > 0)
        {
        }
        else
        {
            throw new System.ArgumentNullException("surl");
        }
        sobj = sobj + "<object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id='Player1' height='379' width='500' standby='Please wait loading file...'>";
        sobj = sobj + "<param name='url' value='" + surl + "' />";
        sobj = sobj + "<param name='src' value='" + surl + "' />";
        sobj = sobj + "<param name='uimode' value='full' />";
        sobj = sobj + "<param name='AutoStart' value='true' />";
        sobj = sobj + "<param name='ShowControls' value='1' />";
        sobj = sobj + "<param name='ShowStatusBar' value='1' />";
        sobj = sobj + "<param name='ShowDisplay' value='1' />";
        sobj = sobj + "<param name='stretchToFit' value='1' />";
        sobj = sobj + "<param name='enablecontextmenu' value='true' />";
        sobj = sobj + "<param name='fullscreen' value='" + isfullsize.ToString() + "' />";
        sobj = sobj + "</object>";
        return sobj;
    }

Thank u.
 
Share this answer
 
v3
Comments
brighteyes24 17-Jul-13 15:22pm    
i tried this code but doesnt work..thank u murali0195
[no name] 18-Jul-13 1:17am    
Am did,bind video file names to dropdown list in formload only.try it.Thank u.
Member 10676688 12-Apr-14 3:25am    
video is not working
wergfdsfdsdfdsffsdsaasds<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
reeeeeeeeeeeeeeeee<br />
 eeeeeeeeeeeeeeeeeeeeeeeeeeeefrg
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900