'Muted audio autoplay is not working in Chrome

According to the Chrome Autoplay policy,

  1. muted audio must be played automatically when it is set the attribute to autoplay true.
  2. iframe allow="autoplay 'src' can play audio with sound

However, it was not working on my code.

The only way to allow to play audios automatically was user interactions and change the browser settings.

Could you check what it is wrong?

(I tested it in Chrome v 89.0.4389.90 64bit)

Test code #1

<body>
    <audio muted controls autoplay preload>
        <source src="https://freesound.org/data/previews/413/413749_5121236-lq.mp3" type="audio/mp3">
  </audio>
</body>

Teest code #2

<body>

<script>
var auto_audio = document.createElement('audio');

auto_audio.controls = true;
auto_audio.muted = true;
auto_audio.volume = 0;
auto_audio.autoplay = true;

var audio_src = document.createElement('source');
audio_src.src = 'https://freesound.org/data/previews/413/413749_5121236-lq.mp3';
audio_src.type = 'audio/mp3';

auto_audio.appendChild(audio_src);
document.body.appendChild(auto_audio);
</script>
</body>

Test code #3

<iframe allow="autoplay 'src'" src="https://freesound.org/data/previews/413/413749_5121236-lq.mp3" style="height:0;width:0;border:0;border:none;visibility:hidden;"></iframe>

Test code #4

<iframe allow="autoplay" src="https://freesound.org/data/previews/413/413749_5121236-lq.mp3" style="height:0;width:0;border:0;border:none;visibility:hidden;"></iframe>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source