我正在制作一个非常简单的音频播放列表,可以在上一首歌曲完成后自动播放每首歌曲。我使用纯javascript和html5音频标签。如何修复此代码以使其正常工作?
var i = ['first.mp3', 'second.mp3', 'third.mp3'];
function playlist() {
for (var i=0; i<2; i++)
}
&#13;
<audio controls="controls" preload="none" onended="playlist()">
<source src="first.mp3" type="audio/mp3">
</audio>
<audio controls="controls" preload="none" onended="playlist()">
<source src="second.mp3" type="audio/mp3">
</audio>
<audio controls="controls" preload="none" onended="playlist()">
<source src="third.mp3" type="audio/mp3">
</audio>
&#13;
答案 0 :(得分:0)
loop
HTML
<audio id="audio" controls preload>
<source src="/files/5913/7240/6617/html5-audio-loop.ogg">
<source src="/files/5513/7240/6617/html5-audio-loop.wav">
<source src="/files/8013/7240/6617/html5-audio-loop.mp3">
</audio>
的JavaScript
document.getElementById('audio').addEventListener('ended', function(){
this.currentTime = 0;
this.play();
}, false);