I'm trying to load a video onto my page using Youtube API.
Youtube specifies that you can enable 'modest branding' (ie. removing youtube logos) by appending the parameter '&modestbranding=1' to the embed url.
The problem I'm having is that the new youtube API embeds the video using javascript eg:
player = new YT.Player('player', {
height: videoHeight,
width: videoWidth,
videoId: videoID,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
This then generates the relevant iframe script, however I'd like to be able to specify modest branding within these parameters. I tried adding an extra parameter:
modestbranding: 1
and
modestbranding: '1'
but neither seems to have any effect.
I realise that one option would be to grab the embed url from the final rendered script and then append the parameter onto the src:
<iframe frameborder="0" allowfullscreen="" id="player" title="YouTube video player" height="368" width="640" src="http://www.youtube.com/embed/<id>?enablejsapi=1"></iframe>
However I would've thought youtube would somehow allow to specify the parameter rather than having to use some dirty hack.
Anyone know how I can do this?
The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played.
Immediately after the YouTube video link, add the “?” character. This let's the code know you're adding some changes or limiters to how that link will display. Then insert the text “modestbranding=1” this parameter removes the gaudy YouTube logo from the player bar.
Modest Branding: When Player Controls is set to YES, you can Hide the YouTube logo by sliding Modest Branding slider to YES.
modestbranding
is a player var and thus should be added with the `playerVars' attribute. Details can be found on the developer docs.
https://developers.google.com/youtube/iframe_api_reference
Here's an example on how to include modestedbranding
or other player vars.
player = new YT.Player('player', {
playerVars: {
modestbranding: true
},
height: videoHeight,
width: videoWidth,
videoId: videoID,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
After some testing
If you set showinfo to 0 then you get the youtube logo even if modesbranding is true.
There is no way to leave the video fully clear it seems.
This will show the logo but not the title
Youtubeplayer = new YT.Player('ytplayer',
{
height: "100%",
width: '100%',
videoId: videoid,
playerVars: {
autoplay: 1, controls: 0, modestbranding: true, showinfo: 1
},
events:
{
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
This will show the title but not the logo
Youtubeplayer = new YT.Player('ytplayer',
{
height: "100%",
width: '100%',
videoId: videoid,
playerVars: {
autoplay: 1, controls: 0, modestbranding: true, showinfo: 0
},
events:
{
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With