Audio
The waveform is the scrubber. Ahead of the playhead it waits as small ticks; behind it the bars draw in, so the part already heard has a shape. Tap or drag anywhere on it to move, or tab to it and use the arrow keys (5 seconds a step, Home and End for the ends). The two buttons either side of play step back and forward 15 seconds.
<div class="doi-audio" data-kicker="Pond Sounds · Side A" data-title="Intro"
data-peaks="26 43 49 43 … 71 66 53">
<audio src="A-01-Intro.mp3" preload="metadata">
<track kind="captions" src="pond-sounds-intro.vtt" srclang="en" label="English">
</audio>
</div>
`data-peaks` is the waveform: one number per bar, 0 to 100, measured from the file ahead of time: about 96 slices for a track of any length, each slice's loudness in decibels, scaled so the loudest is 100 and 42 dB below it is 0 (a linear scale squashes quiet passages flat). Without it the bars are drawn level. The player builds its own controls, so the markup is only the audio element and its labels.
Live
For a live stream, a radio broadcast or a feed with no end, add data-live to the player. There is nothing to seek through, so the skip buttons and the scrubber go: the waveform becomes a level meter that moves while it plays, the times read how long you have been listening and Live, which lights up while it plays, and playing again after a pause rejoins the broadcast where it is now. A stream that drops shows “off the air”. The meter is drawn, not measured from the audio, so it works with any stream, whatever its server allows.
<div class="doi-audio" data-live data-kicker="NOAA Weather Radio" data-title="Phoenix, AZ">
<audio src="https://wxradio.org/AZ-Phoenix-KEC94" preload="none"></audio>
</div>
Use `preload="none"` so nothing downloads until someone presses play. The demo is NOAA Weather Radio KEC94 (162.550 MHz, Phoenix), rebroadcast by the volunteers at wxradio.org; the Atmospheric Observation Program on departmentofinformation.org plays the transmitter nearest the place in the same player. A volunteer stream can go off the air.
Video
The same panel as the audio player, with the picture at the top and nothing laid over it. Below it: back and forward 15 seconds, play, the title, then captions, sound and full screen on the right, and a slim scrubber in Beaurocracy Blue with the times underneath. Tap the picture to play or pause.
Tokyo Sounds promo, a joint production of the Department Satellite Public Affairs Network. Its English subtitles are part of the picture; the CC button adds the Japanese.
<div class="doi-video" data-kicker="Tokyo Sounds" data-title="Promo">
<video src="TS-Ad-01-EN.mp4" poster="tokyo-sounds-promo.webp" preload="none" playsinline>
<track kind="captions" src="tokyo-sounds-promo.ja.vtt" srclang="ja" label="日本語">
</video>
</div>
Human made
Add data-provenance to a video and the Human made label sits on the picture, bottom right. With data-provenance="animate" it stays hidden until the video starts from the beginning, then plays in (the mark scales up, the chip opens out from behind it) and goes again on the next play from the start. Screen readers also get the full sentence, “Non-AI: No AI, generative AI, or robots of any kind were used in the making of this product.”; change either with data-provenance-label and data-provenance-statement. Use it only where it is true. Full screen shows the picture with the label and the browser’s own controls.
<div class="doi-video" data-title="Promo" data-provenance="animate">
<video src="TS-Ad-01-EN.mp4" poster="poster.webp" preload="none" playsinline></video>
</div>
Product gallery
For product pages: the big picture with arrows, and thumbnails underneath with arrows of their own. Swipe the picture on a touch screen, tap the arrows, press the left and right keys while the picture is focused, or tap a thumbnail. A video goes in as a player and gets a thumbnail from its poster. Inside a gallery the video is a perfect square like the pictures, its controls laid over the bottom and fading out while it plays; it pauses when you move off it. Pictures load as you approach them, so lazy-loading plugins can’t leave blank slides.
<div class="doi-gallery" aria-label="Product pictures">
<img src="front.jpg" alt="Front">
<div class="doi-video" data-title="In use" data-provenance="animate">
<video src="in-use.mp4" poster="in-use.jpg" preload="none" playsinline></video>
</div>
<img src="back.jpg" alt="Back">
</div>
Captions
| Provider | Whisper, OpenAI's open speech-recognition model, run on each file before it is published. Nothing is transcribed live and no service is called from the page. |
|---|---|
| Format | A WebVTT file, added as a <track kind="captions"> inside the audio or video. The player then shows a CC button. |
| Defaults | Audio: on, the current line under the player. Video: off, drawn on the picture, since videos often carry their own (the promo above has English burned in). Each choice is remembered. |
| Before publishing | Proofread the file. Whisper slips on names it can't know: Department offices, sub brands, places. Keep cues short, about 40 characters a line (24 for Japanese). |
Behavior
- One player sounds at a time: starting one pauses the others on the page.
- Every control is a real button with a label that says what it will do (“Play”, “Pause”, “Mute”), and each scrubber is a slider that reads out “0:12 of 0:46”.
- Load it on any Department site with the stylesheet and the script:
pencil-box.cssand pencil-box.js, which are Roma’sroma.cssandroma.jswithtl-swapped fordoi-. Players added after the page loads are wired up withDOIPencilBox.media(element). - Long or large videos: use
preload="none"with a poster, so nothing downloads until play.