views:

49

answers:

1

for you tube video integration youtube provides an embed for all the you tube videos what i want is i just provide a link to the user on clicking of which it fetches the embed of that particular video and play that one in my asp.net page how to achieve this can any one help me out it ill be better if you can give some examples along with

+2  A: 

If you look at the embed code for a few different YouTube videos, you will see that the only difference is a video ID (the "fYzblEeAt2U" part of a URL like "http://www.youtube.com/watch?v=fYzblEeAt2U")

Note that this appears twice in the embed code - first in the first param tag, and secondly in the embed tag.

So you just need to serve up the standard embedding code, with that ID being replaced by your back-end code, maybe something like this:

<object width="640" height="385">
  <param name="movie" value="http://www.youtube.com/v/&lt;% =MyVideoID %>&hl=en_GB&fs=1&rel=0"></param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowscriptaccess" value="always"></param>
  <embed src="http://www.youtube.com/v/&lt;% =MyVideoID %>&hl=en_GB&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>
</object>
Carson63000
can you please tell me how to set the video id in code behind in c#
Mac
How experienced a C# / ASP.NET developer are you? <% =MyVideoID %> will insert a variable named MyVideoID from your codebehind file. Declare it with _"protected string MyVideoID;"_ and set it in your _"Page_Load()"_ or wherever. You'll probably be wanting to set it in response to a click event, or from a QueryString parameter or something like that (depends on your design)
Carson63000