ScratchCard icon indicating copy to clipboard operation
ScratchCard copied to clipboard

audio not playing when I click on scratchcard

Open oragvelidze opened this issue 1 year ago • 0 comments

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?

oragvelidze avatar Feb 08 '24 21:02 oragvelidze