Captions drawn apart from the video with track.activeCues

The text track of this video is hidden, so the video draws no captions. The page reads track.activeCues, builds each cue as HTML and the canvas draws that element by itself, away from the frame. Press Play, choose where the captions are drawn, and tap a word to move the video to it.

0:00.0

The video hasn't been played yet.

Show the code a hidden track, cues as elements, three ways to draw them
  1. The markup. The video, a control bar and an empty caption box are children of the canvas. The <track> has no default attribute.
  2. Follow the active cues. track.mode = 'hidden' loads the file without showing it. On cuechange, one element is added for each cue in track.activeCues.
  3. Make an element from a cue. getCueAsHTML() returns a fragment. Time stamps inside the cue arrive as processing instructions, and each word after one gets that time.
  4. Connect the video. requestVideoFrameCallback() gives the media time of the frame on screen, and the words are marked for that time.
  5. Draw. One drawElementImage() call each for the video, the control bar and the captions. The mask mode draws the captions, then draws the frame over them with source-in.
  6. The CSS. The word states are attribute selectors with a colour transition.
  7. The whole library file.

How it works

Live checks

Each check builds its own small video and canvas in a corner of the window. The player above isn't touched.

ResultExperimentDetail

Findings

From Chromium 157 headless with software video decoding, 2026-11-21. The rows above say what your browser does.