+ 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.

14th Sep 2018, 6:28 AM
Moses Odhiambo
Moses Odhiambo - avatar
6 ответов
+ 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.
15th Sep 2018, 8:12 AM
Moses Odhiambo
Moses Odhiambo - avatar
+ 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.
15th Sep 2018, 8:31 AM
Moses Odhiambo
Moses Odhiambo - avatar
+ 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.
15th Sep 2018, 8:03 AM
Janning⭐
Janning⭐ - avatar
24th Jul 2020, 11:11 AM
Raj Srivastava
Raj Srivastava - avatar
+ 2
15th Sep 2018, 8:20 AM
Janning⭐
Janning⭐ - avatar
+ 2
🤔 Fascinating...
15th Sep 2018, 8:37 AM
Janning⭐
Janning⭐ - avatar