如何在HTA文件上播放声音 [英] How to play a sound on an HTA file

查看:87
本文介绍了如何在HTA文件上播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在互联网上搜索了一段时间,并且没有教程解释如何播放声音

Ive been searching the internet for a while now and no tutorial has explained how to play sound

<Audio autoplay>
<source src="sound.mp3" type="audio/mp3">
</Audio>

没有显示错误,但也没有声音播放,感谢所有帮助

No errors are displayed but no sound plays either, all help is appreciated

推荐答案

只需使用 bgsound 元素播放音频文件:

Just simply use bgsound element to play an audio file:

<bgsound src="audio.mp3">

您还可以为 loop 属性指定一个数字,该数字指示音频文件要播放多少次.
如果您想在特定事件发生时播放声音(例如,用户单击按钮),请删除 src 属性,并在需要播放时通过脚本更改此属性的值.声音.例如:

You can also specify a number for loop attribute which indicates how many times the audio file is to be played.
If you want to play your sound whenever a particular event occurs (e.g. the user clicks on a button), remove the src attribute, and change the value of this attribute via your script whenever you need to play your sound. For example:

<bgsound>
<button onclick="playSound()">Play</button>
<script language="javascript">
function playSound()
{
    document.getElementsByTagName("bgsound")[0].src = "audio.mp3";
}
</script>

这篇关于如何在HTA文件上播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆