here is the trick to launch the next song:
music.addEventListener('ended',function(){
How to play another song on the same sound tag:
music.pause(); music.src = "new url"; music.load(); music.play();
Now here is a cool example of a playlist in html5, you can download each song at a time if some clients (mobile) are not happy when you spend traffic, in the following example all the audio are downloaded at the same time have a smooth transition from song to song, loading songs :
//playing flag var musicTracker = 'noMusic'; //playlist audios var audios = []; $(".song").each(function(){ var load = new Audio($(this).attr("url")); load.load(); load.addEventListener('ended',function(){ forward(); }); audios.push(load); }); //active track var activeTrack = 0;
The underline of the witch song plays, with a bit of jquery, yes, the case yes I am lazy, lazy:
var showPlaying = function() { var src = audios[activeTrack].src; $(".song").removeClass("playing"); $("div[url='" + src + "']").addClass("playing"); };
Spell here
Note. If sound does not play, manually check if the audio address is available.
SilentTremor
source share