我想点击按钮播放声音说MP3文件。 但问题是,如果HTML文件和声音文件放在同一目录中然后它可以工作,但如果我必须播放位于任何其他远程URL的声音文件,则无法找到该文件。
有人可以建议我应该怎么做播放远程音频文件吗?
我从这里得到了一个想法: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 :(得分:0)
您确定“player.swf”,“audio-player.js”和“your.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>
答案 1 :(得分:0)
Flash Player安全sanbox可能会导致此类问题。在这种情况下,你需要在mp3文件所在的服务器上放置一个crossdomain.xml文件(我不记得这种文件的确切内容)