#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
/path/to/local-mp3.mp3
<video autoplay controls id="Player" src="http://www.w3schools.com/html/movie.mp4" onclick="this.paused ? this.play() : this.pause();">Your browser does not support the video tag.</video>
<script>
var nextsrc = ["http://www.w3schools.com/html/movie.mp4","http://www.w3schools.com/html/mov_bbb.mp4"];
var elm = 0; var Player = document.getElementById('Player');
Player.onended = function(){
if(++elm < nextsrc.length){
Player.src = nextsrc[elm]; Player.play();
}
}
</script>
它比许多答案都要短,你想要多少曲目它就有多少曲目,它很容易理解,而且它实际上在播放它之前加载了音频(所以它实际上可以工作) ,所以我想我应该把它包括在这里。我找不到任何声音文件在一个运行片段使用,但我测试了我自己的3个声道在 Chrome 和它的工作。检测 ended事件的 onended方法也适用于除 caniuse Internet Explorer 之外的所有浏览器。