+ 3
audio.play() using JS
audio.play() using JS is not working on Sololearn Mobile APP but working on browser , how can I fix itđŹ? https://code.sololearn.com/WUW0CEKydXzI/?ref=app
2 Answers
+ 2
You can't , most browsers don't allow audio to play on it's own you need some user gesture to play the audio .
Like have a onclick event handler function on window and play the audio inside it. When user click anywhere on window , it will play it.
Also there is a howler js library that i have heard can help in playing it without user interaction.
+ 1
You have to use user event like click, dblclick, .... to initiate audio.play() action.