Ex. https://www.bunlongheng.com/sound/police-4
I don't know why the audio is not playing automatically. Is it the restriction by my browser or my code is wrong? I tested in Chrome & Firefox.
<audio id="myAudio" controls autoplay>
<source src="/assets/sounds/police-4.ogg" type="audio/ogg">
<source src="/assets/sounds/police-4.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
As you can see, I've already added autoplay
Click play work, but I need to make it auto-play.
CodePudding user response:
Try adding the word muted after the word autoplay because some other browsers don't support autoplay unless muted
CodePudding user response:
Chromium based internet browsers do not support autoplay. Although to bypass this you can set it to muted autoplay by doing
<audio id="myAudio" controls autoplay muted>
But the audio will not automatically play. The user must manually select the mute button for it to start playing.
For more info visit W3Schools