【发布时间】:2018-08-12 15:29:15
【问题描述】:
我已经在互联网上搜索了一段时间,没有教程解释如何播放声音
<Audio autoplay>
<source src="sound.mp3" type="audio/mp3">
</Audio>
没有错误显示,但也没有声音播放,感谢所有帮助
【问题讨论】:
标签: hta
我已经在互联网上搜索了一段时间,没有教程解释如何播放声音
<Audio autoplay>
<source src="sound.mp3" type="audio/mp3">
</Audio>
没有错误显示,但也没有声音播放,感谢所有帮助
【问题讨论】:
标签: hta
只需简单地使用 bgsound 元素来播放音频文件:
<bgsound src="audio.mp3">
您还可以为 loop 属性指定一个数字,该数字指示音频文件要播放多少次。
如果您想在特定事件发生时播放声音(例如,用户单击按钮),请删除 src 属性,并在需要播放时通过脚本更改此属性的值声音。例如:
<bgsound>
<button onclick="playSound()">Play</button>
<script language="javascript">
function playSound()
{
document.getElementsByTagName("bgsound")[0].src = "audio.mp3";
}
</script>
【讨论】: