Skip to content

Instantly share code, notes, and snippets.

@tim-peterson
Last active December 20, 2015 22:09
Show Gist options
  • Save tim-peterson/6203155 to your computer and use it in GitHub Desktop.
Save tim-peterson/6203155 to your computer and use it in GitHub Desktop.
video.playlist.js loop
//first version
// for continuous play
if(typeof options.continuous=='undefined' || options.continuous==true){
//console.log('options.continuous==true');
player.on("ended", function(){
//console.log('on ended');
index++;
if(index>=trackCount){
//console.log('go to beginning');
index=0;
}
else;// console.log('trigger click next track');
tracks[index].click();
});// on ended
}
//to loop track 1, one time
// for continuous play
if(typeof options.continuous=='undefined' || options.continuous==true){
//console.log('options.continuous==true');
var count=0;//create 2nd counter to loop 1st track
player.on("ended", function(){
//console.log('on ended');
count++;
if(index==0 && count==1) tracks[index].click(); //count==1 if only want to loop 1st track once
index++;
if(index>=trackCount){
//console.log('go to beginning');
index=0;
}
else;// console.log('trigger click next track');
tracks[index].click();
});// on ended
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment