I have html5 audio like this in my page
<audio src="assets/media/bgaudio.mp3" id="audio" autoplay type="audio/mpeg"></audio>
Here is jQuery code.
$(document).ready(function() {
$("#audio").get(0).play();
});
But getting an error when refresh the page.
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl /xX8pDD
Any idea to fix the issue?