user didn't interact with the document first

Viewed 2706

I'm getting an error called Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. Does anyone know how to fix this?

const audioCls = new Audio("/assets/audio/a4.mp3");
setInterval(() => {
  audioCls.play();
}, 1000);
1 Answers

Clicking the document fixed the issue :)

Related