2013-06-20 46 views
0

我想创建一个播放列表,下面的代码,但我似乎得到一些错误。萤火虫说play()不是一个功能。请帮助我花了一天的时间试图寻找解决方案。这里是我的代码:播放多个音频文件

<head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <script>  

     var current, playlist; 
     current = 0; 
     function() { 
      current++; 
      var songs = Array("en_ra1.mp3", "en_ra2.mp3", "en_ra3.mp3", "en_ra0.mp3"); 
      playlist = songs.length; 
      if (current == playlist) { 
       //do nothing or stop 
      } else { 
       this.playOptions = document.getElementById("audio").src = songs[current]; 
       this.playOptions.play(); 
      } 
     } 
    </script> 
    </head> 
<body> 
<audio id="audio" onended="loadplaylist()" src="ny_option1.mp3" controls ></audio> 

注:当我加入了自动播放属性是尽管萤火控制台显示错误的工作就好了。

回答

2

,我没有看到,你声明loadplaylist功能,大概是一个错字

在你的函数要设置 this.playOptions从数组,而不是球员返回的字符串

,我想你的函数应该读的东西像这个:

function loadplaylist() { 
     current++; 
     var songs = Array("en_ra1.mp3", "en_ra2.mp3", "en_ra3.mp3", "en_ra0.mp3"); 
     playlist = songs.length; 
     if (current == playlist) { 
      //do nothing or stop 
     } else { 
      this.playOptions = document.getElementById("audio"); 
      this.playOptions.src = songs[current]; 
      this.playOptions.play(); 
     } 
    }