A
A
andrey_levushkin2020-07-13 10:41:43
JavaScript
andrey_levushkin, 2020-07-13 10:41:43

Is there a workaround for audio tag in html for google chrome?

After the Google Chrome policy changed (a couple of years ago), the browser stopped playing music in the background of the site (audio tag using autoplay). But I found those who managed to get around it.
For example, yesterday I came across a site that can still play music in the background:
https://starper55plys.ru/html/mysik-site/
There was already a similar topic: How to make autoplay work?
It is recommended to add the muted attribute for the audio tag - I didn’t really understand how to do this, because I didn’t find any documentation about the muted attribute.

They also suggested making it in the form of a video tag:

<video id="myaudio" controls="" loop="" autoplay="" name="media" preload="auto" hidden>
<source src="music.mp3" type="audio/mp3">
</video>
  <script>
    var audio = document.getElementById("myaudio");
  		audio.volume = 0.2;
  </script>


More clumsy option:
<iframe hidden src="music.mp3" allow="autoplay" type="audio/mpeg">

But there is no music. Although even the content of the site disappears, just a black screen.

So how can you still try to get around this limitation (as the site from the example above did) and what is this muted attribute to the audio tag?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stepan Germanov, 2020-07-15
@stepvolt

Try with JavaScript
Here - https://javascript.ru/blog/gordon-freeman/fonovaya...

D
Dima Pautov, 2020-07-13
@bootd

Somehow you searched badly
https://www.google.com/search?q=html5+audio+muted&...

N
Nadim Zakirov, 2020-07-13
@zkrvndm

Upload your music to YouTube and embed the video on the site with autoplay enabled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question