Created
November 20, 2015 01:03
-
-
Save michaelgiles/73e2eb73d241bb34b72b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var player = { | |
playVideo: function(container, videoId) { | |
if (typeof(YT) == 'undefined' || typeof(YT.Player) == 'undefined') { | |
window.onYouTubePlayerAPIReady = function() { | |
player.loadPlayer(container, videoId); | |
}; | |
$.getScript('//www.youtube.com/player_api'); | |
} else { | |
player.loadPlayer(container, videoId); | |
} | |
}, | |
loadPlayer: function(container, videoId) { | |
window.myPlayer = new YT.Player(container, { | |
playerVars: { | |
modestbranding: 1, | |
rel: 0, | |
showinfo: 0, | |
autoplay: 1 | |
}, | |
height: 200, | |
width: 200, | |
videoId: videoId, | |
events: { | |
'onStateChange': onPlayerStateChange | |
} | |
}); | |
} | |
}; | |
var containerId = 'ytplayer'; | |
var videoId = 'abc123'; | |
player.playVideo(containerId, videoId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment