Audio tag failed to play under chrome


html

<audio src="./../static/music/10683.mp3" id="eventAudio"></audio>
js

audioFun(){
   let eventAudio = document.getElementById("eventAudio");
   eventAudio.play()
}


audioFun () is called to play sound effects.
is played normally in browsers such as Speed360 and Firefox, but in chrome, Uncaught (in promise) DOMException

is reported.
Jul.19,2022

the new version of chrome is temporarily unavailable, requiring at least one user interaction.


meets this requirement today, so we simply write a hack method, which can be used in actual measurement:
chrome browser

Menu