2015-12-08 85 views
0

我對java不太擅長,在研究網站上音樂循環的簡單播放/暫停按鈕後,我得到了此代碼。它脫機工作正常測試,但上傳到FTP服務器並不在任何瀏覽器中播放音頻和我得到的SyntaxError後:輸入播放/暫停按鈕在線工作但不在線

意外結束繼承人的代碼:

<style> 
button{ border:none; cursor:pointer; outline:none; } 
button#playpausebtn{ 
    background:url(images/sound_on.png) no-repeat; 
    width:20px; 
    height:20px; 
} 
</style> 
<script> 
var audio, playbtn, seek_bar; 
function initAudioPlayer(){ 
    audio = new Audio(); 
    audio.src = "newsongs/Geboren__xsm2.mp3"; 
    audio.loop = true; 
    audio.play(); 
    // Set object references 
    playbtn = document.getElementById("playpausebtn"); 
    // Add Event Handling 
    playbtn.addEventListener("click",playPause); 
    // Functions 
    function playPause(){ 
     if(audio.paused){ 
      audio.play(); 
      playbtn.style.background = "url(images/sound_on.png) no-repeat"; 
     } else { 
      audio.pause(); 
      playbtn.style.background = "url(images/sound_off.png) no-repeat"; 
     } 
    } 
} 
window.addEventListener("load", initAudioPlayer); 
</script> 
+4

javascript!= java –

+0

在調用play()之前在音頻上使用'onload'事件 – Ramanlfc

回答

0

沒關係,我剛發現我自己的錯誤。評論標籤使它無法正確加載!