2011-08-18 119 views
0

我試圖讓聲音爲以下HTML-JavaScript代碼工作......但沒有聲音,而且程序不會說「沒有聲音支持」。不確定是什麼問題 ??HTML JavaScript無法播放聲音?

<html> 
<head> 
<title>Sound Test</title> 
<script type="text/javascript"> 
function PlaySound(){ 
    var sound = document.getElementById("note_c1"); 
    try{ 
     //RealPlayer 
     sound.DoPlay(); 
    }catch (e){ 
     try{ 
      //Windows Media/Quicktime 
      sound.Play(); 
      alert("should hear sound"); 
     }catch(e){ 
      alert("No sound support."); 
     } 
    } 
} 
</script> 
</head> 
<body> 
<h1>Sound Test</h1> 
<embed id="note_c1" src="c1.au" width="0" height="0" autostart="false" enablejavascript="true"/> 
<input type = "button" value="Play the Sound" onClick="PlaySound()"> 
</body> 

+0

我可以知道您使用的是哪種瀏覽器嗎? – Unknown

回答

0

使用http://www.jplayer.org/

我沒有從屬關係 - 它很簡單,高度可配置,可以在更大的一組客戶端上工作,並且有更多的未來證明(並且沒有分叉代碼)。

快樂編碼:)