+ 9
Can anyone tell me how to play audio/sound on page load without user gesture?
If you know then please share a code..
8 Answers
+ 13
https://www.quackit.com/html/codes/html_background_music_codes.cfm
This website explains this perfectly
+ 8
Automatic music play dose not work on chrome browser because hi is very strict.
+ 7
This might help you :
https://www.sololearn.com/learn/HTML/2193/
See the <autoplay> attribute ..........
+ 5
Same link posting twice?
+ 1
Playing sound is basically letting the website use your audio System. Some browsers want you to "pay them" for your work.
+ 1
Due to browser restrictions (especially mobile devices) that isn't always possible.
One workaround that I use is if there is any button that the user would have to click to use audio in the first place, then play and immediately pause the audio. This allows the audio to be played without issues in the future.
An example could be for game sound effects, clicking a start/play button would quickly play then pause the audio to allow it to be played later.
Also, I'm not completely sure about this, but I think that if the browser won't allow js to play audio on-demand, then neither will the autoplay attribute (as other answers have suggested) start it.
0
First link not working, Please give the correct link @river