I'm encountering an issue with triggering audio in my window's load
listener function.
var audio = new Audio();
audio.src = "assets/silence.mp3";
audio.load();
document.getElementById("body").addEventListener(
'touchstart',
function(evt){ audio.play(); audio = 0; },
{capture:false,once:true,passive:true}
);
When using Chrome on Android (with remote debugging open), I tap the screen and it attempts to play the audio. However, it fails and outputs this error to the console:
(index):65 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
I'm wondering how else I can trigger audio in a way that ensures the user initiates it, if not through a user interaction event listener.