Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
How to play a video in asp.net web site by fetching path from database.
Posted
Updated 31-Dec-12 19:54pm
v3
Comments
Member 10208230 27-Feb-14 4:52am    
It's giving error at DBManager as

The name "DBManager" does not exist in the current context

why??

 
Share this answer
 
Comments
__TR__ 22-Dec-12 6:25am    
+5
Thomas Daniels 22-Dec-12 6:26am    
Thank you!
ntitish 22-Dec-12 7:42am    
Download flash web control from http://www.aspnetflash.com/ .

Just add that in to your tool box by right clicking on tool box items and clicking on choose items. If u have already added the tool then select it else browse for dll file and add that...

Now ur tool box contain flash video control that can play flv or swf files.. jus asign

Flash1.MovieURL = "Path of video file from u tube";//Here flash1 is id of flash control

This will work, if not please let me know...



I have taken a data list which displays name of video, description and link button from database..If i click on see video link that will play video in flash control



If u are using only videos from youtube but not playing any videos from ur server or anywhere else u can use following code



protected void lnkSeeVideo_Command(object sender, CommandEventArgs e)
//lnkSeeVideo_Command is event of item template(link button) that is in data list--

{
try
{
string str = Convert.ToString(e.CommandArgument);//str is video id string of a video that is in youtube --- which is fetched from database

lblVideo.Text = string.Format("<div id=\"video{0}\"><object width=\"491\" height=\"343\"><param name=\"movie\" value=\"http://www.youtube.com/v/{0}&rel=1\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/{0}&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"491\" height=\"343\"></embed></object></div>", str);

///We are embedding youtube flash video at runtime in a label, this worked fine for us.
}
catch (Exception ex)
{


}
}

this was the solution i got from one site...www.aspnetflash.com in this web site flash should not used for comercial purpose..i want which will be the good player will set in asp.net
Abhishek Pant 22-Dec-12 10:08am    
follow which one you find best and easy.
 
Share this answer
 
Comments
__TR__ 22-Dec-12 6:25am    
+5
Sandeep Mewara 22-Dec-12 6:28am    
Thanks.
ntitish 22-Dec-12 7:42am    
Download flash web control from http://www.aspnetflash.com/ .

Just add that in to your tool box by right clicking on tool box items and clicking on choose items. If u have already added the tool then select it else browse for dll file and add that...

Now ur tool box contain flash video control that can play flv or swf files.. jus asign

Flash1.MovieURL = "Path of video file from u tube";//Here flash1 is id of flash control

This will work, if not please let me know...



I have taken a data list which displays name of video, description and link button from database..If i click on see video link that will play video in flash control



If u are using only videos from youtube but not playing any videos from ur server or anywhere else u can use following code



protected void lnkSeeVideo_Command(object sender, CommandEventArgs e)
//lnkSeeVideo_Command is event of item template(link button) that is in data list--

{
try
{
string str = Convert.ToString(e.CommandArgument);//str is video id string of a video that is in youtube --- which is fetched from database

lblVideo.Text = string.Format("<div id=\"video{0}\"><object width=\"491\" height=\"343\"><param name=\"movie\" value=\"http://www.youtube.com/v/{0}&rel=1\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/{0}&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"491\" height=\"343\"></embed></object></div>", str);

///We are embedding youtube flash video at runtime in a label, this worked fine for us.
}
catch (Exception ex)
{


}
}

this was the solution i got from one site...www.aspnetflash.com in this web site flash should not used for comercial purpose..i want which will be the good player will set in asp.net
 
Share this answer
 
Comments
ntitish 22-Dec-12 7:44am    
in the above comment i asked the question....can u give me any solution for that..
Abhishek Pant 28-Dec-12 20:52pm    
I think the youtube link you provided will work on runtime from the internet or you have to save your videos in your database.here is a player for every brower support Flash Video Player[^] or why dont you directly embed your videos to play in there..!its easy you can use flash banner tool
http://forums.asp.net/t/1372384.aspx/1[^]

//IN FRONT END
C#
string sqlqueryPlayVideo = "Alumniproc";
                DataSet dsPlayVideo = DBManager.DataAccess.getdata(sqlqueryPlayVideo);
                if (dsPlayVideo.Tables[0].Rows.Count > 0)
                {
                    string path = Server.MapPath("~/");
                    string VideoPath = path + dsPlayVideo.Tables[0].Rows[0]["Gallery_Content"].ToString();
                    if (VideoPath != null)
                    {
                        string fileextenction = "";
                        if (VideoPath.EndsWith(".wmv"))
                        {
                            fileextenction = Path.GetExtension(VideoPath).ToLower();
                            //file.Attributes.Add("value", VideoPath);
                            this.paramMediaPath.Attributes.Add("value", VideoPath);
                        }

                    }
                }

//AT BACK END
<object id="MediaPlayer" width="690" height="300" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
        standby="Loading Windows Media Player components..." type="application/x-oleobject">
        <param name="FileName" id="paramMediaPath"  runat="server" />
        <param name="ShowControls" value="true" />
        <param name="ShowStatusBar" value="false" />
        <param name="ShowDisplay" value="false" />
        <param name="autostart" value="false" />
        <embed type="application/x-mplayer2"

pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" 

width="424" height="379" src="ccent31.wmv"

filename="ccent31.wmv" autostart="0" showcontrols="0" showstatusbar="0" showdisplay="0">

</embed>
    </object>
 
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