我已经在互联网上搜索了一段时间,但没有教程解释如何播放声音
<Audio autoplay>
<source src="sound.mp3" type="audio/mp3">
</Audio>
没有错误显示,但也没有声音播放,感谢所有帮助
最佳答案
只需简单地使用 bgsound 播放音频文件的元素:
<bgsound src="audio.mp3">
您还可以为 指定一个数字循环 指示音频文件要播放多少次的属性。
如果您想在发生特定事件(例如用户单击按钮)时播放声音,请删除 源 属性,并在需要播放声音时通过脚本更改此属性的值。例如:
<bgsound>
<button onclick="playSound()">Play</button>
<script language="javascript">
function playSound()
{
document.getElementsByTagName("bgsound")[0].src = "audio.mp3";
}
</script>
关于hta - 如何在 HTA 文件上播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49102617/