I have created a audio object with new Audio().
const audio = new Audio()
I know, to play a audio user interaction is mandatory. So I tried with the following code.
audio.addEventListener("canplaythrough", () => {
audio.play()
});
But it throws the Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first error again. How to solve this?