Skip to content

Commit

Permalink
Automatically start playing the first song after the last one
Browse files Browse the repository at this point in the history
  • Loading branch information
themagiulio committed Dec 13, 2020
1 parent 6a9fb97 commit 68a92d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions player.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@
};

player.addEventListener('ended', function () {
currentSong.style.fontWeight = 400;
var index = parseInt(currentSong.getAttribute('index')) + 1;
currentSong.style.fontWeight = 400;
if(document.querySelector(`[index="${index}"]`) === null){
index = 0;
}
currentSong = document.querySelector(`[index="${index}"]`);
currentSong.style.fontWeight = 900;
playerSource.src = tracksList['tracks'][index]['file']['mp3-128'];
currentSong.style.fontWeight = 900;
player.load();
player.play();
}, false);
Expand Down

0 comments on commit 68a92d8

Please sign in to comment.