~/todd-fleeman/case-study — session log entry

~/Video Visualizer

started 2026-10-01 · last touched 2026-10-05
0:00 / 0:00
Vidya Verma
Politician
pick a voice

Disclaimer: All videos and voices are AI generated.

why this exists

A video player that shows what it's saying. Choose a person from the list and their clip plays, while a waveform under the video draws the sound in real time. Captions show up in their own space, a line at a time, rather than on top of the picture. Each person is a Sanity document with a video, a poster image, a caption file and a publish date, so new clips go live on schedule without a code change. The play, seek and mute controls are the same component the site uses for audio, since a video element is a media element too. It's built in Next.js and TypeScript, with Web Audio and Canvas for the waveform.

built on / learned
HTML5 Video
Learned
  • Video has audio, too. The Web Audio API can tap a video element the same way it taps an audio element. An analyser node reads the loudness of each frequency every frame, and Canvas draws it as bars mirrored around a center line.
  • One source node per element, ever. Web Audio allows only one source per media element. The audio context, source and gain nodes live in refs, so React's double-run of effects in development doesn't try to make a second one.
  • Mute through a gain node. Once the sound flows through Web Audio, muting goes through a gain node set to 0 or 1.
  • Phones need a nudge. The audio context starts out suspended, so it resumes on play and again when the tab becomes visible. On iPhones, setting the audio session to playback lets the sound play even with the silent switch on.
  • Captions outside the picture. A hidden text track feeds a cuechange listener, and React renders the current line wherever the layout wants it. Keying the line on its text makes each new line animate in. Captions from another domain need crossOrigin set on the video, or the track never loads.
  • One set of controls for every player. Play, seek and mute accept any media element, so audio and video share the same component.
  • Release dates do the scheduling. The query only returns people whose publish date has arrived, so clips can be loaded in early.
where this might go

Seeing sound helps more people than it seems. A waveform tells deaf and hard-of-hearing viewers when someone is talking, and side-by-side captions keep faces visible. Apply that to a gallery of oral histories, where each voice is a person you can choose and read along with. Or a language app where learners watch a speaker's rhythm while they listen. Click a caption line to jump to that moment, and every interview becomes searchable by what was said.