0

I have a website where i put a music to be autoplayed and looped, but it's not working in Chrome. It's work on every browser but not in Chrome. I saw something on the internet that Chrome blocked this option, but i ask this community if they know some answer.

There is the code i used:

<audio src="goliath.webm" autoplay>
<p>Test.</p>
</audio>
  • 1
    People (users) don't like autoplaying music. You have no idea what the person who is viewing the website is doing or their situation, so the website should not play sounds unless requested, because 99% of websites don't play sounds, it is not expected. It can often cause people to abort visiting a website to have uninvited audio chugging at them. This is why Chrome does not autoplay audio. You should reconsider your approach. – Martin Feb 23 '21 at 15:24
  • Yep @Martin is correct. You cannot control the users browser preferences, settings, privacy and the extensions he is using. This is beyond your control. All you can do is add the autoplay option, so you can offer this feature to some of your users. Also, you should not control this feature for a lot of your users will not like it. – Tom Bombadil Feb 23 '21 at 15:29

1 Answers1

0

Here is a solution from another stack overflow page

Apparently using an iframe can bypass the "security measures" chrome placed to block autoplay.

<iframe src="youraudiofile.mp3" type="audio/mp3" allow="autoplay" id="audio" style="display:none"></iframe>
<audio autoplay>
    <source src="youraudiofile.mp3" type="audio/mp3">
</audio>

Credit: Link