2013-06-20 171 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(); 
     } 
    }