0

所以我有一些按钮,人们可以按下这些按钮来收听音频文件。当然,音频文件不能“重叠”,因为那会一团糟。这可行,但现在我希望其中一个文件在网站加载时自动播放,仍然保持这样一个事实,即每当我按下另一个按钮时它就会停止。

这是我到目前为止所得到的:

头:

<script language="javascript" type="text/javascript">
 function playSound(soundfile) {
 document.getElementById("dummy").innerHTML=
 "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"false\" loop=\"true\" />";
 }
 </script>

身体:

<span id="dummy"></span>

<p style="text-align:center;">
<a href="#" onclick="playSound('Sound1.mp3');"> 
<img class="alignnone" width="128" img src="Img1.png" ></a>

<a href="#" onclick="playSound('Sound2.mp3');"> 
<img class="alignnone" width="128" img src="Img2.png"  ></a>

<a href="#" onclick="playSound('Sound3.mp3');"> 
<img class="alignnone" width="128" img src="Img3.png"  ></a>
</p>
4

1 回答 1

0

试试这个 jquery 解决方案:

http://archive.plugins.jquery.com/project/sound_plugin

我在反应时间测试中成功地使用了它,我必须在每次测试之前播放声音。

于 2012-07-30T09:20:01.147 回答