Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created June 29, 2012 17:05
Show Gist options
  • Save chrisallick/3019246 to your computer and use it in GitHub Desktop.
Save chrisallick/3019246 to your computer and use it in GitHub Desktop.
onYouTubePlayerReady = function( playerId ) {
ytplayer = document.getElementById( "video_container" );
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
ytplayer.addEventListener("onError", "onytplayerError");
ytplayer.playVideo();
}
function onytplayerStateChange(newState) {
if( newState == 0 ) {
playNextVideo();
}
}
// on error just go to next vid
function onytplayerError(error) {
playNextVideo()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment