Audio
The waveform is the scrubber. Ahead of the playhead it waits as small ticks; behind it the bars draw in. 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 buttons either side of play step back and forward 15 seconds.
<div class="tl-audio" data-kicker="Tomato Lab" data-title="Test tone"
data-peaks="12 40 66 … 71 66 53">
<audio src="tone.mp3" preload="metadata"></audio>
</div>
`data-peaks` is the waveform: one number per bar, 0 to 100, measured from the file ahead of time (about 96 slices, each slice's loudness in decibels, the loudest 100 and 42 dB below it 0). 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="tl-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 picture at the top of the same panel, then back and forward 15 seconds, play, the title, captions, sound and full screen on the right, and a slim scrubber with the times underneath. Tap the picture to play or pause. Full screen shows the browser’s own controls.
<div class="tl-video" data-kicker="Tomato Lab" data-title="Demo clip">
<video src="clip.mp4" poster="clip.webp" preload="none" playsinline></video>
</div>
Human made
Add data-provenance to a video and the Human made label sits on the picture, bottom right. 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. 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. Use it only where it is true.
<div class="tl-video" data-title="Demo clip" data-provenance="animate">
<video src="clip.mp4" poster="clip.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; it pauses when you move off it.
<div class="tl-gallery" aria-label="Product pictures">
<img src="front.jpg" alt="Front">
<div class="tl-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
Add a <track kind="captions"> (WebVTT) inside the audio or video and the player shows a CC button. Audio starts with captions on, the current line under the player; video starts with them off, drawn on the picture. Each choice is remembered. Proofread machine captions before publishing.
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, and each scrubber is a slider that reads out “0:12 of 0:46”.
- Load it with the stylesheet and the script:
roma.cssand roma.js. Players added after the page loads are wired up withTLRoma.media(element). - Long or large videos: use
preload="none"with a poster, so nothing downloads until play.