disable showing thumbnails at the end of video in iframe apii - youtube-api

I use youtube iframe api for embedding some videos. I observe that at the end of the video, api displays some thumbnails/videos (as recommendations) for next watch.
How can I disable that? I want it to be blank or can I customize? I do something like this:
function onYouTubeIframeAPIReady() {
player = new YT.Player('player1', {
height: YTPlayerHeight,
width: YTPlayerWidth,
playerVars: { 'autoplay': 1, 'showinfo' : 0, controls: 0 },
videoId: firstVideoId,
events: {
'onReady': onReady,
'onStateChange': onPlayerStateChange
}
});
}
Pleas help

Setting rel: 0 as one of the playerVars will disable the end screen. All of the supported parameters are listed in the documentation.

Just setting parameter - related: false

Related

youtube-iframe-api remove suggestion thumbnails at bottom of video

Could somebody tell me how to remove youtube suggestion thumbnails on embedded video.
I am using iframe api. It feel like it should be easy. But i just can't find anything on google on how to do it.
tag.src = "https://www.youtube.com/iframe_api";
function initPLayer(playerDivId){
return new YT.Player(playerDivId, {
height: '390',
width: '640',
videoId: '4EDMR75lrKY',
events: {
'onReady': onPlayerReady1,
'onStateChange': onPlayerStateChangePlayer1
}
});
}
Thanks for help!
I knew it was obvious :P.
There is thing called player parameters.
Rel:
This parameter indicates whether the player should show related videos when playback of the initial video ends. Supported values are 0 and 1. The default value is 1.

Removing youtube watermark from youtube player

How can I remove youtube watermark in youtube player or please suggest me any other player in which youtube watermark can be removed, while playing youtube videos.
player = new YT.Player('playerId',
{
width: getParameterByName('width'),
height: getParameterByName('height'),
html5: 1,
videoId: getParameterByName('videoid'),
playerVars: {'enablejsapi':1,'rel':0,'playsinline':1 ,'autoplay': parseInt(getParameterByName('auto')),'showinfo':0, 'controls': parseInt(getParameterByName('ctrl')),'wmode':'transparent', 'modestbranding':1 ,'color':'white','frameborder':0},
events:
{
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError':onPlayerError
}
});
I added the particular key 'modestbranding':1 in my code but nothing is changed, still I am getting the youtube icon at bottom right corner.
Here I am adding a screenshot of my video.

YouTube iframe api won't play from click handler on iOS

I am using the Youtube iframe api to show a custom thumbnail and play button over an embedded video. It is working everywhere (including android) except for iOS, where I get "If playback doesn't begin shortly, try restarting your device" behind the thumbnail. If I hide the thumbnail, I can play the video using Youtube's play button (before using my controls) and the html5 play button (after using my controls)
I am aware of the restriction on autoplaying videos, but this should get around that because it is triggered by a click handler, and works on android which has the same restriction
function loadVideo(videoID, title, description, thumbUrl, waitPlay) {
var playBtn = jQuery(".playerThumb");
jQuery(".playerTitle").text(title);
jQuery(".playerDesc").text(description);
jQuery(".playerEmbed").replaceWith("<div id='video' class='playerEmbed'></div>");
playBtn.css("background-image", "url(" + thumbUrl + ")").show().off('click').removeClass("ready");
jQuery("html, body").animate({ scrollTop: 0 }, 400, "swing", function(){});
ytPlayer = new YT.Player('video', {
videoId: videoID,
playerVars: {
rel: 0,
showinfo: 0,
autoplay: (waitPlay === true ? 0 : 1)
},
events: {
'onReady': onReady,
'onError': function(e){console.error(e);},
'onStateChange': function(e){if (e.data == YT.PlayerState.PLAYING) jQuery(".playerThumb").fadeOut();}
}
});
function onReady(e) {
playBtn.click(function() {ytPlayer.playVideo();}).addClass("ready");
if (waitPlay !== true) {
if (ytPlayer.getPlayerState() == YT.PlayerState.PLAYING) {
playBtn.hide();
}
}
}
}
How can I get this to work on iOS? Is my only option to just use the default play button for iOS?
Had the same issue and found the solution.
It turns out that on iOS you can't overlay the youtube video with any div, the user needs to click directly on the youtube iframe for the video to start.

some questions on youtube IFrame API

With IFrame API, whether a video is played with html5 container or flash container depends on a lot of factors. I'm wondering: is it possible to set some parameter or call a function to force the player to be flash(or html5)?
besides, rel=0 seems not work in Iframe API, when I set it to 0, the related videos are still shown, is there something wrong with my code? thanks!
player = new YT.Player('player', {
height: '300', //720
width: '400', //1280
videoId: 'S2Rgr6yuuXQ',
playerVars: { 'rel': 0 }, // or rel: 0, rel: '0', all don't work
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError': onErrorDetected,
'onPlaybackQualityChange': onQualityChange
}
});
I think that the iframe option does not include a parameter to select html5 or flash option , because the iframe API uses the best option automatically.
you can try to specify to use HTML5 if available:
Force HTML5 youtube video
YouTube video in HTML5
and you can use the SWFObject option to use only the flash player in the client (if the client supports flash ..)
Using playerVars: { html5: 1 } loads an iframe with a html5=1 attribute in the src, similar to Force HTML5 youtube video.
Replace
playerVars: { 'rel': 0 }
with
playerVars: { 'rel': '0' }

Remove YouTube related videos in this script

I have seen this script to auto-mute video's from youtube embedded on a site:
How do I automatically play a Youtube video (IFrame API) muted?
The code is available on fiddle:
http://jsfiddle.net/9RjzU/3/
However I would like to know what to add to this code to prevent related videos appearing?
Thanks
Azzam
In your situation, all that is needed is to add 'rel': 0 to the PlayerVars parameters, like so:
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
playerVars: {
'autoplay': 1,
'controls': 1,
'autohide': 1,
'wmode': 'opaque',
'rel': 0
},
videoId: 'JW5meKfy3fY',
events: { 'onReady': onPlayerReady }
});
}
You might also be interested in the full list of parameters available for the YouTube iframe API, found here: https://developers.google.com/youtube/player_parameters#Parameters

Resources