我正在创建一个个人小型网站,我想在上面播放一些歌曲。我试图做的是以下
<script type="text/javascript">
var i=1;
var nextSong= "";
var audioPlayer = document.getElementById('audio');
audioPlayer.onended = function(){
i++
nextSong = "Music/"+i+".mp3";
audioPlayer.src = nextSong;
audioPLayer.load();
audioPlayer.play();
if(i == 37) // this is the end of the songs.
{
i = 1;
}
}
</script>
<audio id="audio" src="Music/1.mp3"controls="controls" autoplay="autoplay" align=""> </audio>
但是我无法让它工作,它只是播放第一首歌并且不执行我尝试过提醒 i 状态的 JS,但它什么也没做。