An editor can load a video successfully and still fail to play it. If your UI flips to “playing” the moment play() is invoked, the controls can easily describe a playback state the browser never actually entered.

Wait for the playback outcome

HTMLMediaElement.play() returns a Promise. Handle both resolution and rejection cleanly, and always keep a clear, accessible way for the user to trigger playback manually. The MDN HTMLMediaElement.play() reference outlines the common reasons—such as autoplay policies or media constraints—why script-initiated playback may be rejected.

This gets trickier in a background remover video workflow where the original clip and the processed output live in separate media elements. Even if one preview starts playing without issue, that does not guarantee the companion element started too.

Make the button describe reality

Avoid optimistic UI updates that switch the button label to “Pause” or “Playing” without rolling back on failure. Keep playback state separated from media readiness: “ready to preview” tells you the asset can be shown, while “playing” means playback is actively running.

Guard against stale async completions as well. If the user swaps clips while a play() promise is still pending, verify that the settled result still belongs to the active media element before updating UI state. A delayed fulfillment or rejection should never overwrite controls for a newly selected clip.

Test the refusal path deliberately

Verify the failure flow explicitly instead of assuming happy-path playback:

  1. Open the page in a fresh browser session and trigger play() before any user gesture, then test clicking the visible play button.
  2. Include a broken or unreachable media source so asset load errors are handled on their own path rather than mislabeled as autoplay blocks.
  3. Finish by pausing, swapping in another clip, and starting playback again.

The goal is a preview control that accurately reflects what happened and gives the user a clear next step. A silent promise rejection should never be the only clue behind a frozen video preview. Similarly, a loading spinner should always transition into a clear, readable state rather than lingering as the sole indicator that playback was refused.