title: How to fix audio not auto playing when page is loaded? - html
body: <p>I'm trying to play an audio when page is loaded, it should be really simple however i can't accomplish it.</p>
  
  <p>The problem is that it is not playing, i tried checking the state of autoplay (True/False) and it says it does playing when page is loaded although it does not, also tried making a function which will change the auto play state to True but it didnt do anything ...</p>
  
  <pre><code>&lt;html&gt;
  &lt;head &gt;
      &lt;audio controls autoplay id='myAudio'&gt;
              &lt;source src="..//sounds//firstpagesong.mp3" type="audio/mp3"&gt;
              &lt;source src="..//sounds//firstpagesong.mp3" type="audio/mp3"&gt;
              Your browser does not support the audio element.
      &lt;/audio&gt;
  &lt;/head&gt;
      &lt;body onload="tryy()"&gt;
          &lt;p id="demo"&gt;&lt;/p&gt;
          &lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
          &lt;script&gt;
              function myFunction() 
              {
                  var x = document.getElementById("myAudio").autoplay;
                  document.getElementById("demo").innerHTML = x;
              }
              function tryy()
              {
                  var audio = document.getElementById("myAudio");
                  audio.autoplay = true;
                  audio.load();
              }
          &lt;/script&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Also looked up for similar question here and tried thier solution as well but none of them worked.</p>