Created
November 30, 2018 15:25
-
-
Save jefBinomed/cf3c1593836438339edf3c838ff8328c to your computer and use it in GitHub Desktop.
2018-countdown-audio-v0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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