+ 6
'Play() can only be initiated by a user gesture' workaround
I get this exception on Android devices when I try to play audio via JavaScript - 'play() can only be initiated by a user gesture' Do you guys know any workaround or alternative? Thanks.
6 Respuestas
+ 5
Janning⭐ That happened when I tried to use play() without any event handlers. I wanted the music to play automatically, but now, it only plays when the user clicks the "up/down/--->/<---" labels. I guess it's no longer a big deal.
+ 5
Janning⭐ works on PC but not on Android. I've learned that Google only allows play() on Android when it's used along with DOM events.
+ 3
If you're talking about the background music in this code:
https://code.sololearn.com/Wis4OmrSYmM9/?ref=app
I can only tell you that I can't reproduce the error you're referring to. It works fine on my device.
+ 3
https://code.sololearn.com/WlFK9rl4z9tu/?ref=app
Check this game
+ 2
Not sure if this will help you out:
https://www.w3schools.com/jsref/prop_audio_autoplay.asp
+ 2
🤔
Fascinating...