title: How to autoplay audio in any browser?
body: <p>I'm making a website, and I need that, when the page loads, a background sound plays automatically.</p>
  <p>Howerver, into my research, I found out that Google changed the autoplay policies to avoid ads. The result is that anything with sound and the autoplay prop just stopped working.</p>
  <p>I tried a lot of things people suggested on internet, I'll list a few at the end of this post.</p>
  <p>So, I managed to find <a href="https://olafwempe.com/how-to-enable-audio-and-video-autoplay-with-sound-in-chrome-and-other-browsers-in-2019/" rel="nofollow noreferrer">this website here</a>. The programmer suggested to use an <strong>iframe with a 1 second mp3 file with no sound just before the audio tag</strong>. And it works perfectly on his website!</p>
  <p>So, my issue is... I'm using the <strong>same</strong> 1-second mp3 file that he used. And I'm using the <strong>same</strong> html structure that he used (just changing the path of my files and the id names). <em>And it didn't work for me.</em></p>
  <pre><code>&lt;iframe src=&quot;path/silence.mp3&quot; type=&quot;audio/mp3&quot; allow=&quot;autoplay&quot; id=&quot;audio&quot; style=&quot;display:none&quot;&gt;&lt;/iframe&gt; 
  &lt;audio id=&quot;bgsound&quot; autoplay loop&gt;
      &lt;source src=&quot;path/natureza.mp3&quot; type=&quot;audio/mp3&quot;&gt;
  &lt;/audio&gt;
  </code></pre>
  <p><strong>Can someone help me to figure out how the same code structure can work on his website and doesn't work on mine?</strong> All the related topics I found about this issue in Stack Overflow hasn't a definitive solution, so I thought that maybe, with a website that brings this funcionality working, someone can help me digging this case.</p>
  <hr />
  <p>Things I already tried before and ended up with no success:</p>
  <ul>
  <li>Use the prop muted together with the autoplay and, with a timeout on JavaScript, give the false value to the muted prop after a few seconds.</li>
  <li>Don't use the autoplay prop and activate the play() method on loading the page.</li>
  </ul>