问题
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
回答1:
Just simply use bgsound element to play an audio file:
<bgsound src="audio.mp3">
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>
来源:https://stackoverflow.com/questions/49102617/how-to-play-a-sound-on-an-hta-file