Answer the question
In order to leave comments, you need to log in
How to play sound in browser?
Hello,
I'm trying to autoplay sound when opening a site,
I googled several options, none of them work (Chrome browser),
below is a code example - how can I still do this?
And if you need a sound when you click a button on the site, too, how to do it?
Dear Admin. please do not delete this question with the wording that all this
can be found through the search - everything that is there does not work)
<audio src="click.mp3" autoplay="autoplay"></audio>
или так
<audio autoplay>
<source src="click.mp3" type="audio/mpeg">
</audio>
или так
<audio src='click.mp3' autoplay='autoplay' loop='loop'></audio>
Answer the question
In order to leave comments, you need to log in
Display a notification that the site uses cookies and add a button to close this notification. When you press the button, you use the event from it to activate the audio.
Previously, yes, it was possible to automatically play, but now the browser developers have removed this feature. Only if clicked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question