How to play audio automatically in background? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

How to play audio automatically in background?

I want my audio automatically play in my web page background. How to do it. Audio is played on touching the screen.

18th Sep 2020, 11:59 AM
VSR [ DEV ]
VSR [ DEV ] - avatar
2 Answers
+ 2
You can't play audio automatically since it annoys the user ,so you need some action to play the audio now , or you can use web audio api to fetch the whole audio stream and play it and yes it plays automatically atleast for me
18th Sep 2020, 12:16 PM
Abhay
Abhay - avatar
+ 1
window.onclick = function () { var audio = document.get ...... audio.play(); };
18th Sep 2020, 12:02 PM
Namit Jain
Namit Jain - avatar