By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,291 Members | 3,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,291 IT Pros & Developers. It's quick & easy.

Playing YouTube Videos In ASP.NET

100+
P: 233
I am looking to play youtube.com videos in ASP.NET. I would use the embedded link that is available on the site, but I want to ability to change the source video link based on button clicks. Any help would be appreciated.
Jul 27 '09 #1
Share this Question
Share on Google+
4 Replies


P: 41
Don't really understand what you're wanting to do. It seems like that's just some simple html.

Are you wanting a "Next Video" button? If so, do you have a list of videos that you want the user to be able to scroll through? Or something completely different?
Jul 27 '09 #2

100+
P: 233
I want there to be a default video on the page load. Underneath this, I would put a but for video 2, another for video 3, and so on. OnClick would change the source from the default video to that of video 2 or 3 or 4.
Jul 27 '09 #3

P: 41
It would use an updatepanel with the button click as the trigger.

This is what I've come up with so far. The button would now have to be programmed to cycle through the videos

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <title>Untitled Page</title>
  8. </head>
  9. <body>
  10.     <form id="form1" runat="server">
  11.     <div>
  12.     <asp:ScriptManager ID="ScriptManager1" runat="server">
  13.                 </asp:ScriptManager>
  14.         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  15.             <ContentTemplate>
  16.  
  17.                 <embed runat="server" id="Video1" src="http://www.youtube.com/v/MUl0oKQmnus&hl=en&fs=1&" 
  18.     type="application/x-shockwave-flash" allowscriptaccess="always" 
  19.     allowfullscreen="true" width="425" height="344"> </embed>
  20.             </ContentTemplate>
  21.             <Triggers>
  22.                 <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
  23.             </Triggers>
  24.         </asp:UpdatePanel>
  25.     </div>
  26.     <asp:Button ID="Button1" runat="server" Text="Button" />
  27.     </form>
  28. </body>
  29. </html>
This site shows how to update with a random picture on a timer, but you can modify it a little to use videos and buttons instead of a timer, like I've started to do. http://weblogs.asp.net/dmiyamasu/arc...and-timer.aspx

It's in C#, which I know very little about, and I'm trying to translate it into VB.

I'll let you know if I figure it out. You may beat me to it :D\

Jesse
Jul 27 '09 #4

100+
P: 233
I suppose I should have noted that I was not concerned with whether or not the entire page update, so an updater panel is not necessary. I came up with a very simple, possibly dirty, solution.

Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head runat="server">
  3.     <title></title>
  4.     <script runat="server" type="text/C#">
  5.         protected void PlayVideo(string url)
  6.         {
  7.             VideoPlayer.Attributes["src"] = url;
  8.         }
  9.         protected void VideoSRC1(object sender, System.EventArgs e)
  10.         {
  11.             PlayVideo("http://www.youtube.com/v/SQDlsbn349Y");
  12.         }
  13.         protected void VideoSRC2(object sender, System.EventArgs e)
  14.         {
  15.             PlayVideo("http://www.youtube.com/v/9joKTNM_DaM");
  16.         }
  17.         protected void VideoSRC3(object sender, System.EventArgs e)
  18.         {
  19.             PlayVideo("http://www.youtube.com/v/P7YkJxQT_0Y");
  20.         }
  21.     </script>
  22. </head>
  23. <body>
  24.     <form id="form1" runat="server">
  25.     <div>
  26.     <embed runat="server" id="VideoPlayer" src="http://www.youtube.com/v/SQDlsbn349Y" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"> </embed>
  27.     </div>
  28.     <asp:LinkButton ID="LinkButton1" OnClick="VideoSRC1" runat="server">Video 1</asp:LinkButton><br />
  29.     <asp:LinkButton ID="LinkButton2" OnClick="VideoSRC2" runat="server">Video 2</asp:LinkButton><br />
  30.     <asp:LinkButton ID="LinkButton3" OnClick="VideoSRC3" runat="server">Video 3</asp:LinkButton><br />
  31.     <div><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/A5xRqVZgE-c&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/A5xRqVZgE-c&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>
  32.     </form>
  33. </body>
  34. </html>
Jul 28 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.