Skip to content

Instantly share code, notes, and snippets.

@jefBinomed
Created November 30, 2018 15:25
Show Gist options
  • Save jefBinomed/cf3c1593836438339edf3c838ff8328c to your computer and use it in GitHub Desktop.
Save jefBinomed/cf3c1593836438339edf3c838ff8328c to your computer and use it in GitHub Desktop.
2018-countdown-audio-v0
// Index of the current song in the playlist
var indexPlaylist = 0;
// The playlist of songs to play
var playListSongs = [
'The_Spin_Wires_-_Blackout_Romeo.mp3'
];
// Load the song in parameter and play it
function playSound(url){
audioElt.pause();
audioElt.src = url;
audioElt.play();
}
// Skip to the next song (and start from 0 if we overflow the index of array)
function nextSong(){
try{
playSound("assets/songs/"+playListSongs[indexPlaylist]);
indexPlaylist = (indexPlaylist + 1) % playListSongs.length;
}catch(err){
console.error(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment