javascripthtmlaudiovideo

HTML 5 video or audio playlist


Can I use a <video> or <audio> tag to play a playlist, and to control them?

My goal is to know when a video/song has finished to play and take the next and change its volume.


Solution

  • you could load next clip in the onend event like that

    <script type="text/javascript">
    var nextVideo = "path/of/next/video.mp4";
    var videoPlayer = document.getElementById('videoPlayer');
    videoPlayer.onended = function(){
        videoPlayer.src = nextVideo;
    }
    </script>
    <video id="videoPlayer" src="path/of/current/video.mp4" autoplay autobuffer controls />
    

    More information here