Set up simple code for an audio playlist of two mp3's and tested in JSFiddle...seemed to be working, but on upload, only plays the first clip in Chrome and Safari, and plays nothing at all in Opera and Firefox. I'm using both mp3's and ogg's so maybe it's about my "ended" function...? "ended" doesn't have to mean "loaded" right? Help!, anyone...?
JS:
var chant = document.getElementById("music");
chant.addEventListener("ended", function() {
chant2 = document.getElementById("music2");
chant2.play();
});
HTML:
<audio id="music" autoplay="autoplay"><br>
<source src="http://www.siddhicenter.org/media/GANAPATIVEDCSTUTI.ogg" type="audio/ogg" /><br>
<source src="http://www.siddhicenter.org/media/GANAPATIVEDCSTUTI.mp3" type="audio/mpeg" /><br>
Your browser does not support the audio element.<br>
</audio>
<audio id="music2" loop="loop" ><br>
<source src="http://www.siddhicenter.org/media/OmNamahShivaya.ogg" type="audio/ogg" /><br>
<source src="http://www.siddhicenter.org/media/OmNamahShivaya.mp3" type="audio/mpeg" /><br>
Your browser does not support the audio element.<br>
</audio>
Thanks in advance...
`s as they don't belong inside an audio tag, also make sure to place your script either after the audio tags or wrap it inside the DOM ready/window's load event. It won't work in FF or Opera because the browser can't find the ogg files in the path you specified (either they're not public or in another folder/different name, so I commented those out). – Fabrício Matté Aug 20 '12 at 23:12