0

I have a simple HTML page where I would want to play audio when the page loads.

I have added a simple HTML5 audio tag with autoplay property but I am getting the following error.

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://developer.chrome.com/blog/autoplay/

I checked all the options and solutions on the web, and on most of the pages, I am getting video tags with the muted property set to true which won't work for me.

Here is what I tried and did not work:

  1. Simple HTML5 Audio tag with autoplay.
  2. Add play call to document load event.
  3. Added play call to click handler of a button with display:none and triggered its click event.

in all of the cases mentioned above, I am getting the same error i.e.

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://developer.chrome.com/blog/autoplay/

Please help me here.

Thanks in advance!!!

Akshay Khale
  • 8,151
  • 8
  • 50
  • 58

0 Answers0