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:
- Simple HTML5 Audio tag with autoplay.
- Add play call to document load event.
- 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!!!