[ BLOG ]For Frontend Engineers · 6 min read

HTML Video Not Playing? Check These Settings

Published · Updated

If an HTML video will not play, check the file URL, response headers, codec, and autoplay settings. The steps below help identify which part is failing.

First, identify the kind of failure

Open the page in a browser with developer tools visible. Keep the Network and Console panels open, reload, and interact with the player once. The first useful clue is often the moment at which playback stops.

SymptomCheck firstLikely layer
Video request is red or missingRequest URL and statusPath, deployment, or security policy
Request returns HTMLResponse body and Content-Type404 page or app-shell fallback
Player says the source is unsupportedContainer, codec, and MIME typeFile or server metadata
Controls play, but autoplay does notmuted and the play() rejectionAutoplay policy
Video starts late or cannot seekMP4 faststart and range responsesProgressive delivery

A video opening in QuickTime Player proves that a local decoder can read the file. It does not prove that the deployed URL is correct, the server labels the response correctly, or every target browser supports the tracks inside the container.

1. Verify the URL and response before changing the file

In the Network panel, select the media request and answer four basic questions:

  1. Does the requested URL exactly match the deployed filename, including letter case?
  2. Does it return a successful response rather than a redirect loop, 404, or 403?
  3. Is the response actually binary video rather than your site’s HTML error page?
  4. Is Content-Type video/webm for WebM or video/mp4 for MP4?

This catches a common single-page-app failure: an unknown asset path returns the app shell with 200 OK. The status looks successful, but the body is HTML and the browser cannot decode it as video.

The MDN video element reference notes that an incorrect server MIME type can prevent video from displaying. The type on a nested <source> helps the browser decide whether to try a file; it does not change the server’s response or repair the media.

curl -I https://example.com/media/product-demo.mp4

For this MP4, look for Content-Type: video/mp4. Run the same check against the exact production URL, not a local development path.

2. Separate the container from the codec

An .mp4 or .webm extension names a container. The container holds encoded video and, sometimes, audio tracks. A browser may understand the container but not the codec or profile inside it. Renaming clip.mov to clip.mp4 changes none of those structures.

You can ask the current browser about a proposed media type with canPlayType():

const video = document.createElement("video");

console.log(video.canPlayType("video/webm"));
console.log(video.canPlayType("video/mp4"));

An empty string means the browser cannot play that declared type. maybe or probably is only a capability signal; the browser still has to fetch and decode the real file.

Inspect the file with a media-information tool or your encoder. If its codec is unsupported by your target browser, export a compatible delivery copy from the original master. Changing HTML attributes will not change the encoded tracks.

3. Check each listed source

If your player offers two formats, test both. This example prefers WebM and offers MP4 as an alternative:

<video
  controls
  playsinline
  preload="metadata"
  poster="/media/product-demo-poster.webp"
  width="1280"
  height="720"
>
  <source src="/media/product-demo.webm" type="video/webm" />
  <source src="/media/product-demo.mp4" type="video/mp4" />
  <a href="/media/product-demo.mp4">Download the product demo</a>
</video>

Browsers attempt the source list sequentially, as documented in MDN’s HTML video and audio guide. Confirm both URLs independently in the Network panel. One valid source should not hide a stale path or wrong response type on the other.

If you need the format tradeoffs behind this pairing, see WebM vs MP4 for the web.

4. Treat autoplay failure as its own problem

If clicking the controls starts playback, the source is playable. The remaining failure is probably autoplay policy rather than encoding.

For a silent decorative loop, use the boolean attributes directly:

<video autoplay muted loop playsinline preload="metadata">
  <source src="/media/loop.webm" type="video/webm" />
  <source src="/media/loop.mp4" type="video/mp4" />
</video>

autoplay="false" does not turn autoplay off; the attribute’s presence makes it true. Remove the attribute when you do not want it. Also remember that browsers can still decline autoplay according to user settings and context.

If JavaScript starts the video, inspect the Promise returned by play(). MDN documents NotAllowedError for policy-blocked playback and NotSupportedError for an unsupported source in its play() reference:

const video = document.querySelector("video");

video.play().catch((error) => {
  console.error(error.name, error.message);
  // Keep a visible play control available.
});

Do not make essential content depend on autoplay. A visible, keyboard-accessible play control gives the visitor a reliable path when automatic playback is blocked.

5. Check MP4 faststart and byte-range delivery

MP4 metadata is often written after the media data. For progressive web playback, moving the moov index to the beginning lets the browser find what it needs earlier. The official FFmpeg format documentation describes +faststart as a second pass that moves this index to the start.

Range requests let a client request part of a resource, which is useful for media seeking and partial access. Test the deployed response:

curl -sS -o /dev/null -D - \
  -H "Range: bytes=0-1023" \
  https://example.com/media/product-demo.mp4

A range-capable response normally returns 206 Partial Content with a Content-Range header. The MDN range request guide explains the request and response headers. If playback works but seeking stalls, inspect the CDN, object storage, proxy, and application server for stripped or ignored range behavior.

Re-encode only when the file is the problem. Correct the URL, response type, or server configuration when those checks fail.

6. Read the media error instead of the poster

A poster can remain visible after playback fails, so the player’s appearance is not a diagnosis. Log the video element’s error:

const video = document.querySelector("video");

video.addEventListener("error", () => {
  console.error({
    code: video.error?.code,
    message: video.error?.message,
    currentSrc: video.currentSrc,
    networkState: video.networkState,
    readyState: video.readyState,
  });
});

The MediaError code reference groups failures into aborted, network, decode, and unsupported-source categories. Browser messages vary, but the category plus currentSrc usually tells you where to investigate next.

If the Console reports a Content Security Policy violation, review the page’s media-src policy. If media lives on another origin, check that origin’s delivery and any cross-origin requirements for the way you use the video. Do not loosen security headers broadly just to make the warning disappear.

Retest after fixing the cause

Check the exact public URL in each supported browser. If you changed the encode, inspect image quality and audio sync too. Use the compression guide for size checks and the poster guide for the preview image.