RSS Feed

How to Play a YouTube Video in ASP.NET Web Application

January 11, 2012 by Sourabh Sharma

In this article we are going to play a YouTube video file in our web application in asp.net. Sometimes we need to play the video in our application. This article will help you to perform this task in the easiest way. I have used a TextBox, Button and Div control to perform this task. Later in this article you will get the code to playing Video file in your asp.net project.

 


Free Download:
 Play Video : Demo Project

 

Source Code:

<asp:TextBox ID=”txtfileurl” runat=”server” Width=”713px”></asp:TextBox>
<asp:Button ID=”btnplay” runat=”server” onclick=”btnplay_Click”
Text=”Play Video” />

<object width=”600″ height=”380″>
<param name=”movie” value=’<%#”http://www.youtube.com/v/” + par %>’ />
<param name=”allowFullScreen” value=”true” />
<param name=”allowscriptaccess” value=”always” />
<embed type=”application/x-shockwave-flash” width=”600″ height=”380″ src=’<%#”http://www.youtube.com/v/” + par %>’ allowfullscreen=”true” allowscriptaccess=”always”></embed>
</object>

Code Page:
protected string par;
protected void btnplay_Click(object sender, EventArgs e)
{
par = txtfileurl.Text;
this.DataBind();
}


No Comments »

No comments yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>