title: I inconsistently get the "play() failed because the user didn't interact with the document first" error when trying to automatically play some audio
body: <p>When the page loads I want an audio file to play automatically. It worked once, but when I refreshed I got the "play() failed because the user didn't interact with the document first" error. When I changed some code it worked once again but after refreshing I kept getting the error.</p>
  
  <p>I've tried simulating a click which, as I said above, worked once. </p>
  
  <p>This is the code I have right now:</p>
  
  <pre><code>$(".header-bg").click();
  console.log("clicked");
  
  $(document).ready(function() {
      console.log("loaded");
      $('#medieval-music')[0].play();
  });
  </code></pre>
  
  <p>The two console logs get logged but the music doesn't play.</p>