Skip to content

audio not playing when I click on scratchcard #51

@oragvelidze

Description

@oragvelidze

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions