Fix du passage à la piste suivante.

This commit is contained in:
Klafyvel 2018-03-28 19:13:06 +02:00
parent 4cd6b830a9
commit 22af46bbf1

View file

@ -30,29 +30,25 @@ function onPlayerReady(event) {
function play() {
player.loadVideoById(tracks[current_link]);
player.playVideo();
document.getElementById(current_link).classList.add('bg-success');
document.getElementById(current_link).classList.remove('bg-secondary');
}
function next() {
if (current_link < (tracks.length -1)) {
current_link += 1;
play();
}
setCurrent(current_link + 1);
}
function prev() {
if (current_link > 0) {
current_link -= 1;
play();
}
setCurrent(current_link - 1);
}
function setCurrent(c) {
if(c > 0 && c < tracks.length) {
document.getElementById(current_link).classList.remove('bg-success');
document.getElementById(current_link).classList.add('bg-secondary');
if(c >= 0 && c < tracks.length) {
if(current_link >= 0 && current_link < tracks.length){
document.getElementById(current_link).classList.remove('bg-success');
document.getElementById(current_link).classList.add('bg-secondary');
}
current_link = c;
play();
document.getElementById(current_link).classList.add('bg-success');
document.getElementById(current_link).classList.remove('bg-secondary');
}
}