ScratchCard
ScratchCard copied to clipboard
audio not playing when I click on scratchcard
Guys please help...
I'm trying to add a scratching sound effect while scratching but the browser gives policy error:
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
var scratchsound = document.getElementById("scratching_audio"); $(".scratchcard_wrapper").on("touchmove", function () { scratchsound.muted = false; scratchsound.play(); });
I have to click second time and then it plays.
very strange, if I bind the touch or click event to anything other than the scratchcard container - it works instantly! What the problem?