0

I'm developing a web that needs to work on computers, smartphones, and iPhones. I'm using the audio HTML tag with autoplay attribute and it doesn't work as expected i.e. audio does not play automatically

<audio id="audio3" autoplay>

What am I doing wrong here?

Hyyan Abo Fakher
  • 3,497
  • 3
  • 21
  • 35
Shir Grinblat
  • 137
  • 2
  • 11
  • 1
    Is [this any use to you](https://developers.google.com/web/updates/2017/09/autoplay-policy-changes) – RiggsFolly Sep 10 '18 at 15:29
  • 1
    Possible duplicate of [Chrome 64 Mobile Android not preload and not autoplay muted videos](https://stackoverflow.com/questions/48492314/chrome-64-mobile-android-not-preload-and-not-autoplay-muted-videos) – RiggsFolly Sep 10 '18 at 15:29
  • So why it's working in chrome on computers and not on android devices? – Shir Grinblat Sep 10 '18 at 15:32
  • Did you manage to complete the whole thread provided by RiggsFolly ? – dbl Sep 10 '18 at 15:42

1 Answers1

0

You have to add the muted and autoplay attributes together like below

<audio id="audio3" autoplay muted>

Chrome's autoplay policies changed in April 2018, and are as follows

  1. Muted autoplay is always allowed

  2. Autoplay with sound is allowed if:

    • User has interacted with the domain (click, tap, etc.).
    • On the desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously played video with sound.
    • On mobile, the user has added the site to his or her home screen.
  3. Top frames can delegate autoplay permission to their iframes to allow autoplay with sound

Refer google docs for more information

nkshio
  • 1,060
  • 1
  • 14
  • 23
  • 1
    Also, there is a permissions option in Chrome Browser in Android now that the user can select to allow sounds in autoplay. – zeta Aug 20 '19 at 03:24