Youtube Javascript API - Disable Related Videos

That's right, this is poorly documented, or I don't see it in the documentation. I don’t want any companion videos ( ?rel=0 ) using the JavaScript API.

 $players[$vidIdPlaceholderRef] = new YT.Player('player_' + $vidIdPlaceholderRef, { height: '550', width: '840', videoId: $vidId }); 

- this is what I have.

I also tried:

 $players[$vidIdPlaceholderRef] = new YT.Player('player_' + $vidIdPlaceholderRef, { height: '550', width: '840', videoId: $vidId + '?rel=0', rel : 0 }); 

bad luck. Does anyone know an option that can be added (tried rel : 0 with no luck)

+49
javascript youtube-api
Nov 16
source share
3 answers

"rel" is the player parameter, as indicated here:

https://developers.google.com/youtube/player_parameters#rel

To add player parameters to iframe players, you need to specify the playerVars property for the second constructor argument (at the time of writing, this is documented here and on the IFrame API documentation page )

eg.

 new YT.Player('playerid', { height: '550', width: '840', videoID: 'video_id', playerVars: {rel: 0}, }); 
+112
Nov 16 '12 at 14:12
source share

If you use SWFObject, you just need to do something like this:

 function loadVideo() { var params = { allowScriptAccess: "always" } , atts = { id: "myvideo" } ; //NOTE THE END OF THE BELOW LINE vvvvvv swfobject.embedSWF("https://www.youtube.com/v/[video id here]?enablejsapi=1&playerapiid=myvideo&version=3&rel=0" , "videoplaceholderid" , "768", "432", "8", null, null, params, atts); } 

Just add rel=0 to the end of your URL.

+1
May 9 '14 at 2:18
source share

No need to code the API, now it can be easily done with

Handset power button → Show more → check the option “Show suggested videos when the video ends”

0
Nov 10 '16 at 2:34
source share



All Articles