2011-01-05 39 views
-1

我想單擊一個按鈕並播放聲音,如MP3文件。 但問題是,如果HTML文件和聲音文件被放置在同一個目錄然後它的作品,但如果我必須播放位於任何其他遠程URL的聲音文件,那麼它的文件無法找到。在背景中的HTML網頁中播放遠程音頻

有人可以建議我應該怎麼做播放遠程音頻文件?

我從這裏一個想法:http://wpaudioplayer.com/standalone

代碼:

<html> 
     <head> 
      <title>Your website</title> 
      <script type="text/javascript" src="audio-player.js"></script> 
      <script type="text/javascript"> 
       AudioPlayer.setup("player.swf", {width: 290}); 
      </script>  
     </head> 
     <body>  
      <p id="audioplayer_1">Alternative content</p> 
      <script type="text/javascript"> 
      AudioPlayer.embed("audioplayer_1", 
{soundFile: "http://www.otherwebsite.com/play.mp3"}); 
      </script>  
     </body> 
    </html> 
+0

您應該問那些編寫Flash音頻播放器的人。 – 2011-01-05 10:49:24

+1

所以你的上面的例子不起作用,即使'play.mp3'存在於那個位置? – 2011-01-05 10:49:52

+0

你確定「player.swf」,「audio-player.js」和「your.mp3」的路徑是正確的嗎?你最好試着編寫這些文件的絕對路徑。 – Alex 2011-01-05 10:52:12

回答

0

你確定 「player.swf」, 「音頻player.js」 和「您的路徑。 MP3「是否正確?你最好試着編寫這些文件的絕對路徑。

<html> 
     <head> 
      <title>Your website</title> 
      <script type="text/javascript" src="http://www.website.com/path/audio-player.js"></script> 
      <script type="text/javascript"> 
       AudioPlayer.setup("http://www.website.com/path/player.swf", {width: 290}); 
      </script>  
     </head> 
     <body>  
      <p id="audioplayer_1">Alternative content</p> 
      <script type="text/javascript"> 
      AudioPlayer.embed("audioplayer_1", 
{soundFile: "http://www.otherwebsite.com/play.mp3"}); 
      </script>  
     </body> 
    </html> 
+0

PLZ看到我的評論有問題,音頻文件不是wid我有我的網址不同的地址/網址 – Swati 2011-01-05 10:57:53

0

Flash Player安全sanbox會導致此類問題。在這種情況下,您需要在mp3文件所在的服務器上放置一個crossdomain.xml文件(我不記得這樣的文件的確切內容)