在背景中的HTML网页中播放远程音频
问题描述:
我想单击一个按钮并播放声音,如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>
答
你确定 “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
答
Flash Player安全sanbox会导致此类问题。在这种情况下,您需要在mp3文件所在的服务器上放置一个crossdomain.xml文件(我不记得这样的文件的确切内容)
您应该问那些编写Flash音频播放器的人。 – 2011-01-05 10:49:24
所以你的上面的例子不起作用,即使'play.mp3'存在于那个位置? – 2011-01-05 10:49:52
你确定“player.swf”,“audio-player.js”和“your.mp3”的路径是正确的吗?你最好试着编写这些文件的绝对路径。 – Alex 2011-01-05 10:52:12