473,666 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Playing YouTube Videos In ASP.NET

233 New Member
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
4 12682
jmprescott
41 New Member
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
mcfly1204
233 New Member
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
jmprescott
41 New Member
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
mcfly1204
233 New Member
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

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

Similar topics

2
3660
by: AngelDude | last post by:
I've done loads of googling trying to find an answer to this question....so advice, experience would be appreciated. I downloaded a software application last week and among other things, it churns out the code for emedding youtube videos into a web page, using a freeware flv movie player and NOT the one youtube usually supplies to webmasters. It's a cool feature which I would really like to use, but I am uncertain as to how legal...
0
906
by: Brian Schmalisch | last post by:
Hello, I hope that you can help me. I submit a character string to my application with several videos. I then would like to play these files as an endless loop after each other in the WMP. How can one solve something like that? Brian
1
3946
by: linksterman | last post by:
I want to make a simple app to overlay subtitles on youtube videos. Is there a way to do this and keep the files hosted on youtubes servers (eg just overlay the text with another flash app)? I have researched simple FLV players as a way to overlay text, but so far it seems youtube is being very hard at making the direct URL to the FLV very hard to obtain.
0
1394
by: jayfer | last post by:
I'm not sure if this is the right thread, considering I have no idea how to do this. I'm designing a website for a friend who wants his youtube videos to be on the site. I'd like to make it so when he uploads a new video to youtube from his channel, a code or a script can grab the video and post it on his site. If that isn't possible, can he upload the videos to his host server and a code can grab it and put it in the right spot on his site? ...
0
1073
by: Baltej Singh | last post by:
Here i am going to elaborate more about my query! I am building an online web application, in which i using TCPDF PHP Library (http://www.tcpdf.org), i am able to add all HTML Content there, but i am not able to add Youtube Embed Codes there, i am able to add Images, text styles etc. Can someone let me know can i do that? I am in a very tight deadline and i need to complete that as soon as possible. I can know Videos can be added using...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.