Skip to content

Instantly share code, notes, and snippets.

@dvidsilva
Created January 22, 2014 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvidsilva/8568622 to your computer and use it in GitHub Desktop.
Save dvidsilva/8568622 to your computer and use it in GitHub Desktop.
Something bla bla bla bla
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
playerVars: { 'rel':0 , 'autoplay': 1, 'loop':1, 'controls':0, 'start':00, 'autohide':1,'wmode':'opaque' },
videoId: 'j0bhd6AkGFk',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.mute();
// event.target.setSize(width:100, height:750);
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
event.target.playVideo();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment