Click here to Skip to main content
16,018,158 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
like in my form application in asp.net i hv taken a combo box label and 2 button....on selection of item from combo box the video should be played in label and on clicking the stop button on the form the video should stop.....
please suggest me code for this....

thanking you;
Posted
Updated 26-Sep-13 21:39pm
v2
Comments
What have you tried?
Sampath Lokuge 27-Sep-13 3:40am    
Check this link : http://www.codeproject.com/Questions/619087/Playing-Video-on-ASP-Net-Csharp-Web-Page

1 solution

Hi...
In aspx:
XML
<asp:Label ID="lbltxt" runat="server" Text="Select Video file :" ForeColor="Brown" style="font-weight: 700"></asp:Label>

<asp:dropdownlist id="ddlvideo" runat="server" height="25px" appenddatabounditems="true" forecolor="DarkOliveGreen" onselectedindexchanged="DropDownList1_SelectedIndexChanged" width="170px" style="font-weight: 700" autopostback="True" xmlns:asp="#unknown"></asp:dropdownlist>

<asp:literal id="Literal1" runat="server" xmlns:asp="#unknown"></asp:literal>

In aspx.cs:
C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                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();
            }
        }

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 + "<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/' width='624' height='379' src='surl' filename='surl' autostart='1' showcontrols='1' showstatusbar='1' showdisplay='1'></embed>";
            sobj = sobj + "</object>";

            return sobj;
        }

Thank u.
 
Share this answer
 
v3

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