Created
January 22, 2014 22:23
-
-
Save dvidsilva/8568622 to your computer and use it in GitHub Desktop.
Something bla bla bla bla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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