Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

HTMLMediaElement.play() failed because the user didn’t interact with the document first — what can I do?

Illustration without a description Illustration without a description

The browser rejected play() because the page did not meet its autoplay requirements. This often happens when code tries to start audible media on load. Inspect when playback was requested and whether it followed a user action such as pressing Play.

 

Call play() from the user’s control and handle its returned Promise. If the design calls for muted autoplay, verify that it works in the target browser and leave a way to start playback manually when it does not.

 

Test that path with autoplay restricted. The interface should reflect the actual playback result, so users still have a usable control if the automatic attempt is rejected.

 

const video = document.querySelector('video'); const button = document.querySelector('#play'); button?.addEventListener('click', () => { video?.play().catch(error => console.warn(error.name)); });

 

Test playback from a real button click and verify that a denied autoplay attempt leaves a visible Play control.