html5音频不播放下一首歌

时间:2016-03-16 16:52:44

标签: html5 html5-video html5-audio

我有像这样的html5代码

<audio controls autoplay>
   <source src="song/1.mp3" type="audio/mpeg">
   <source src="song/2.mp3" type="audio/mpeg">
   <source src="song/3.mp3" type="audio/mpeg">
   Your browser does not support the audio element.
</audio>

为什么它只播放最新歌3.mp3?如何让它自动播放所有歌曲1.mp2->2.mp3->3.mp3

1 个答案:

答案 0 :(得分:0)

您可以为每个音频使用单独的标记

<audio controls autoplay>
  <source src="song/1.mp3" type="audio/mpeg">
   Your browser does not support the audio element.
</audio>
<audio controls>
  <source src="song/2.mp3" type="audio/mpeg">
   Your browser does not support the audio element.
</audio>
<audio controls>
  <source src="song/3.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

或创建一个播放列表控件,如https://www.script-tutorials.com/html5-audio-player-with-playlist/