Search code examples
javascripthtmlplaylist

html5 audio tag with playlist


I used the html5 audio tag to have an player and I'm trying to play more then one song.

<audio id="mp3player" type="audio/mp3" autoplay="true" controls="controls" autobuffer="autobuffer" src='#'>
            Your browser doesn't support the html5 audio tag.

I started a mp3 file by:

music=document.getElementById("mp3player");
musik.src='mp3/me1.mp3';

The problem is that is that I want to use a playlist. Is there something like a m3u playlist. I also found somthing with an music.onend but I didn't find a documention neither did it work for me? Any suggestions.


Solution

  • Use event listeners using vanilla JS or your favorite JS library to trigger the nextsong function.

    See Media Events, specifically the ended event.