A cassette deck drawn from the controls of an <audio> element

The play key, the mute key, the counter and the tape position slider below are the native controls of one <audio controls> element, laid out by CSS and drawn piece by piece by a canvas. The canvas adds the cassette, whose reels turn with currentTime. Press the play key, drag the slider, and use Rewind and Forward.

The tape hasn't been played yet.

Show the code native controls in a grid, drawn in pieces
  1. The markup. An <audio controls> element and two buttons, each a drawable child of the canvas.
  2. Lay out the native controls. ::-webkit-media-controls-panel accepts display: grid, and each named part accepts a grid position, a size, a font and a colour.
  3. Draw the element in pieces. The nine-argument drawElementImage() copies one row or one cell of the element. The counter gets a glow, a pressed key is drawn 4 px lower, and the play glyph is drawn again, large, on the cassette label.
  4. Put the hit-test region back. Every partial draw moves it. A last full-size draw inside an empty clip restores it.
  5. The cassette. Drawn with canvas paths from audio.currentTime and audio.duration.
  6. The level meters. An AnalyserNode on audio.captureStream(), which doesn't change what the element plays.
  7. Rewind and Forward. Two lines each.

How it works

Live checks

Each check builds its own small deck in a corner of the window. The deck above isn't touched. Checks that play the tape do so muted.

ResultExperimentDetail

Findings

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