0

Team,

My code

<audio autoplay id='myAudio' > 
     <source src="abc.mp3" type="audio/mp3">  
     <source src="abc.mp3" type="audio/mpeg">   
</audio>

As this was not working a function was called onload and mocked the event of clicking a button. to resolve the error "play() failed because the user didn't interact with the document first" My chrome build is 78.xx . I know google have disabled this feature . I tried with iframe also but doesnt work. Any help is appreciated.

Paul
  • 4,160
  • 3
  • 30
  • 56
mandan
  • 69
  • 1
  • 11
  • https://stackoverflow.com/a/50742427/8230810 suggests you need to add `muted` for autoplaying to work on Chrome 66+ – James Whiteley Nov 29 '19 at 13:50
  • sir this is for audio tag and not video tag Thanks – mandan Nov 29 '19 at 13:59
  • Probably the same problem though. Someone on that link suggests it's an intentional feature of Chrome to stop new tabs playing unprompted noise, so it's probably more of an audio thing on the video tags anyway. – James Whiteley Nov 29 '19 at 14:01

1 Answers1

0

Google Chrome only allows you to use autoplay on the next scenarios:

  • If muted is also added to the audio tag.
  • User has interacted with the domain (click, tap, etc.)
  • The user has added the site to their home screen on mobile or installed the PWA on desktop.

Chrome knows if the interaction is genuine or if it's mocked, so I don't suggest that way. My suggestion is make your website a PWA, or think a way to make the user interact with the website.

Source: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

Heisenbug
  • 213
  • 1
  • 6
  • Thank you sir 1.unknown attribute muted says my editor when used with audio 2.That interaction is the problem here..here i want to give some instructions on load – mandan Nov 29 '19 at 14:20
  • I think the problem nº1 is a problem of your editor. Here you have a working example: https://codepen.io/jhervas/pen/oNgvLGQ – Heisenbug Nov 29 '19 at 17:05