When the page loads I want an audio file to play automatically. It worked once, but when I refreshed I got the "play() failed because the user didn't interact with the document first" error. When I changed some code it worked once again but after refreshing I kept getting the error.
I've tried simulating a click which, as I said above, worked once.
This is the code I have right now:
$(".header-bg").click();
console.log("clicked");
$(document).ready(function() {
console.log("loaded");
$('#medieval-music')[0].play();
});
The two console logs get logged but the music doesn't play.