close

[Fixed] Uncaught (in promise) DOMException: play() failed because the user didn’t interact with the document first

Today We are Going To Solve Uncaught (in promise) DOMException: play() failed because the user didn’t interact with the document first in Javascript. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Uncaught (in promise) DOMException: play() failed because the user didn’t interact with the document first Error?

  1. How to Fix Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first Error?

    To Fix Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first Error just Mute the video. To solve this error you have to mute the video. You can use the below code for that in HTML. Lets see this: <video loop muted autoplay id="videomain"> <source src="videoname.mp4" type="video/mp4"> </video>

  2. Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first

    To Fix Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first Error just Use the below code. You can use the below code to solve your issue: playVideo() { const media = this.videoplayer.nativeElement; media.muted = true; // without this line it's not working although I have "muted" in HTML media.play(); }

Solution 1 : Mute the video

To solve this error you have to mute the video. You can use the below code for that in HTML. Lets see this:

<video loop muted autoplay id="videomain">
  <source src="videoname.mp4" type="video/mp4">
</video>

Solution 2 : Use the below code

You can use the below code to solve your issue:

playVideo() {
    const media = this.videoplayer.nativeElement;
    media.muted = true; // without this line it's not working although I have "muted" in HTML
    media.play();
}

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

Leave a Comment