0

I have normal html file in that i add one audio tag with autoplay attribute , when the page loaded sometimes it's playing automatically sometimes it's not playing can you please help me to fix this issue ...

// src link is from google drive
<audio  autoplay>
<source id="my_audio" src="https://docs.google.com/uc?export=download&id=11wfYWiukbIZJQnDL385jQs2SGQA5ESbL">
</audio>

Code cracker
  • 316
  • 1
  • 5
  • 20

1 Answers1

0

Suggestion:

When I tested it on my end, I do not get the same intermittent issue with audio not auto-playing using HTML <audio> autoplay attribute with an audio source that's residing on Google Drive. Also, I have checked the public Google issue tracker and there's no active reports about audio from Google Drive not auto-playing when being used as an audio in an html file.

Perhaps, you can try this implementation from this similar answer:

Recently many browsers can only autoplay with sound off, so you'll need to add muted attribute to the audio tag, that is not make sense, so in my opinion the best way is adding document.getElementById('audio').play(); after your tag. Take a look at this code:

  <audio controls loop style="display:none" id="my_audio">
      <source src="https://docs.google.com/uc?export=download&id=11wfYWiukbIZJQnDL385jQs2SGQA5ESbL" type="audio/mpeg">
  </audio>
  <script>
    document.getElementById('my_audio').play();
  </script>

src and id above were tweaked to your actual code

You may also want to check the answers from How to make audio autoplay on chrome

SputnikDrunk2
  • 3,398
  • 1
  • 5
  • 17