Disable related videos on a embedded Youtube player

Submitted by fabio on Thu, 2007-08-23 12:19.

Youtube recently added a new feature to the video player used to embed Youtube videos on other website.

The new default player, once the video completes playing, will display a list of related videos.

While this feature could be useful for some users it is probably not wanted on Youtube video aggregation websites.

Fortunately it's possible to disable related videos.
Let's see how.

The default player

Let's take a cool video (I'm a windsurfing addicted).

The default embed code Youtube suggest us is

<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/Yc_J_kXaFSw" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</object>

Which will generate this:

As you can see, at the end of the video the player will display something like this:

Youtube related videosYoutube related videos

Disabling related videos

The trick is to attach to the player URL (http://www.youtube.com/v/Yc_J_kXaFSw) the rel=0 parameter.

The player URL will became http://www.youtube.com/v/Yc_J_kXaFSw&rel=0

Just update the embed code with the new URL:

<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</object>

The player now looks like:

We don't have more related videos!

Let's use valid XHTML code

Unfortunately the embed code provided by Youtube isn't valid XHTML code and does not pass the W3C's XHTML validation.

This is really bad as creating valid XHTML web pages is valuable and professional. In some countries it is even required by law for public administration websites.

So we can use something like

<!--[if !IE]> <-->
<object type="application/x-shockwave-flash" width="425" height="350"
data="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0">
<!--> <![endif]-->
<!--[if IE]>
<object type="application/x-shockwave-flash" width="425" height="350"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<![endif]-->
<param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0" />
<p>Your browser is not able to display this multimedia content.</p>
</object>

The above code, which come from my Drupal video module, is valid XHTML code and works with the most used web browsers.

The above code generate:

Your browser is not able to display this multimedia content.

Conclusions

You are now able to control the behavior of Youtube player related video and post on your website Youtube videos following XHTML standards.

References

New! Related Videos Appearing on Embeds at Youtube Blog

thanks

Submitted by aQuib (not verified) on Thu, 2008-06-19 21:03.

i know this article is old but it still great information.

THANKS this is what i looked for

Submitted by henrik (not verified) on Fri, 2008-02-08 13:21.

Dear Fabio

indeed this is what i was searching for.

while searching i found the parameters

for automatic starting

&autoplay=1

and looping

&loop=1

the youTube video

does anybody know even more or has a parameter-list?
--

hope they keep it working like this for a while!!

ciao
henrik, berlin, germany

Thanks Henrik for your

Submitted by fabio on Fri, 2008-02-08 15:01.

Thanks Henrik for your comments and for sharing your finds. Good to know that we can also autoplay and loop youtube videos.

I think that the youtube embeddable player actually have a lot more of paramenter but unfortunately Youtube doesn't provide documentation for them.

Yes.. A Youtube parameter-list might be really useful.

disable links

Submitted by Matt (not verified) on Fri, 2008-01-25 01:12.

one other person asked how do you disable links and your answer was that the question wasn't clear so let me ask the same thing but in a different way.
when you embed a Youtube video, by either the way you described or the way youtube suggests, the embedded video has a start button in the center of the video view window. click on it and the video plays. if you mouse over any other part of the video window, you have the little finger. if you click, you are taken to the youtube video channel that that video is from...
how do you disable this link so that only the video plays, but is not a link back to youtube?

thank you in advance,
_Matt

Unfortunately I don't think

Submitted by fabio on Fri, 2008-01-25 02:05.

Unfortunately I don't think that the embeddable youtube player permits to disable the link you are talking about.

Probably Youtube doesn't permits disabling this link as it want to drive visitors to its website.

you can achieve this with a

Submitted by bart venken (not verified) on Fri, 2008-02-01 14:30.

you can achieve this with a div and some css.
standard size of a youtube clip is 425px / 355px.
the height of the controlbar (with play/pause button) is 37px. create a div with width = 425px and height = 318px. make sure you position it over the embedded youtube clip - give it a background-color red (#ff0000). that way you can easily check if the clip is completely covered by the div (except for the controlbar ofcourse). now, this div SHOULD have a background color, otherwise the clip will still be clickable. but you can't see the clip! well : simply give it transparency! like this (background-color styling should come first) :

background: #ff0000;
filter:alpha(opacity=0);
-moz-opacity: 0;
opacity: 0;

You also should use the AC_RunActiveContent.js in order for the clip to activate itself ...

Would someone be so kind and

Submitted by George (not verified) on Sat, 2008-03-22 20:08.

Would someone be so kind and post working example code (div's and css) so I can disable the click through to YouTube when you click a video outside of the "Play" button image, as explained by 'bart venken' in his earlier post above.

Thank you so much.

Example code: disabling Flash link to YouTube on embedded videos

Submitted by Phillip G (not verified) on Sat, 2008-04-05 03:52.

This was a great solution, thanks bart! In response to George's question, here is the code I came up with that works great. I put all the formatting in the stylesheet, so I can just add some div layers quickly in the body of the document.

ALSO, I did NOT use the "autoplay" code, since I have several videos on my page and don't want them to play automatically. In addition, I opted to make a "frame" of div layers, so the user can still click on the center "play" button to start the video. The downside is that after the video is started, the user could still click the center and end up on YouTube, but I think it's an acceptable compromise.

Hopefully this code will post ok. Please note you'll need to change the [ and ] to < and >, respectively. See it work and view the source at www.perfectpocketpets.com. Click on "Thinking about getting a sugar glider" and it will take you to the questions page. You can see it in action there. Enjoy!
- Phillip
####### SAMPLE CODE ########
<style type='text/css'>
.vidOverlayContainer {
position:relative;
width:300px;
height:1px;
}

.vidOverlayTop {
position:absolute;
filter:alpha(opacity=0);
-moz-opacity:0;
opacity:0;
top:0px;
left:0px;
width:300px;
height:100px;
background-color:#FF0000;
z-index:3;
}

.vidOverlayLeft {
position:absolute;
filter:alpha(opacity=0);
-moz-opacity:0;
opacity:0;
top:100px;
left:0px;
width:125px;
height:30px;
background-color:#0000FF;
z-index:3;
}

.vidOverlayRight {
position:absolute;
filter:alpha(opacity=0);
-moz-opacity:0;
opacity:0;
top:100px;
right:0px;
width:125px;
height:30px;
background-color:#0000FF;
z-index:3;
}

.vidOverlayBottom {
position:absolute;
filter:alpha(opacity=0);
-moz-opacity:0;
opacity:0;
top:130px;
left:0px;
width:300px;
height:100px;
background-color:#FF0000;
z-index:3;
}
</style>

<div class='vidOverlayContainer'>
   <div class='vidOverlayTop'></div>
   <div class='vidOverlayLeft'></div>
   <div class='vidOverlayRight'></div>
   <div class='vidOverlayBottom'></div>
</div>
<object width='300' height='251'... YOUTUBE EMBED CODE CONTINUES HERE...>

####### END SAMPLE CODE #######
Hope that works ok. Enjoy!

awesome find! thanks!

Submitted by FWD (not verified) on Thu, 2007-12-13 22:53.

awesome find! thanks!

how do you disable the links

Submitted by Anonymous (not verified) on Sun, 2007-11-25 05:47.

how do you disable the links on youtube videos?

mmm...

Submitted by fabio on Mon, 2007-11-26 12:00.

This question is not really clear to me.. What do you mean?

thanks

Submitted by Anonymous (not verified) on Mon, 2007-10-29 17:04.

that;s good info. one of my clients i did a video for doesn't want to advertise anybody else!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <h2> <h3> <h4> <b>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.

More information about formatting options

1 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.