views:

3493

answers:

6

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.

A: 

There's no way to define a playlist using just a <video> or <audio> tag, but there are ways of controlling them, so you can simulate a playlist using JavaScript. Check out sections 4.8.7, 4.8.9 (especially 4.8.9.12) of the HTML5 spec. Hopefully the majority of methods and events are implemented on modern browsers such as Chrome and Firefox (latest versions, of course).

Felix
+4  A: 

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.onend = function(){
    videoPlayer.src = nextVideo;
}
</script>
<video src="path/of/current/video.mp4" autoplay autobuffer controls />

More information here => http://www.whatwg.org/specs/web-apps/current-work/#video

markcial
A: 

It has been done there : http://www.jezra.net/projects/pageplayer

Laurent Debricon
A: 

Yep, you can simply point your src tag to a .m3u playlist file. A .m3u file is easy to construct -

#comments start with a pound sign

#and files are listed by their path

#hosted mp3's need absolute paths but file system links can use relative paths http://servername.com/path/to/mp3.mp3 http://servername.com/path/to/anothermp3.mp3

Sorry for the poor editing the code block wasn't working well

Marcus Pope
A: 

Yep, you can simply point your src tag to a .m3u playlist file. A .m3u file is easy to construct -

Dude...how do you do this?

In html5 video tag?

This would be mint for me if it works.

Ron FIsh
This is not an answer, and your quoted content is not marked as such.
David Dorward
A: 

could it be that chrome doesn't support .m3u files?

Yecki