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() { function play() {
player.loadVideoById(tracks[current_link]); player.loadVideoById(tracks[current_link]);
player.playVideo(); player.playVideo();
document.getElementById(current_link).classList.add('bg-success');
document.getElementById(current_link).classList.remove('bg-secondary');
} }
function next() { function next() {
if (current_link < (tracks.length -1)) { setCurrent(current_link + 1);
current_link += 1;
play();
}
} }
function prev() { function prev() {
if (current_link > 0) { setCurrent(current_link - 1);
current_link -= 1;
play();
}
} }
function setCurrent(c) { function setCurrent(c) {
if(c > 0 && c < tracks.length) { if(c >= 0 && c < tracks.length) {
document.getElementById(current_link).classList.remove('bg-success'); if(current_link >= 0 && current_link < tracks.length){
document.getElementById(current_link).classList.add('bg-secondary'); document.getElementById(current_link).classList.remove('bg-success');
document.getElementById(current_link).classList.add('bg-secondary');
}
current_link = c; current_link = c;
play(); play();
document.getElementById(current_link).classList.add('bg-success');
document.getElementById(current_link).classList.remove('bg-secondary');
} }
} }