Audio player

A recording with its own controls over a real <audio>: play, scrubber (optionally over a waveform), times, skips, speed, mute and volume, download, and a transcript that follows along. dsAudio drives it.

Anatomy

 ▁▃▅▇▅▃▁▂▄▆▄▂▁▃▅▇▅▃▁▂▄▆▄▂▁▃   ← scrubber: a native range over the bars, --ds-audio-at lights the played part
 0:42                  −3:18   ← elapsed, remaining
 [1×]   [↺10] [ ▶ ] [10↻]   [🔊 ───] [⤓]
 ──────────────────────────────
 0:00  Maya  Hi, it is Maya.   ← cues: ol, the current one aria-current
 0:04        About Thursday.

Compact is one row: play, the scrubber, the time, speed, download.

PartTokenWhy
Playsurface-inverse / on-inverse, size-11 (full)The one control that matters, heaviest.
Other controlstext-fg-muted, hover:bg-fg/10, rounded-full
Barsfg/15, played fgThe played part is the same bars clipped by clip-path: inset() from --ds-audio-at, one custom property per frame, no layout. RTL clips from the other side.
Track (no waveform)fg/15, fill fg, clipped the same way
Timestext-meta tabular-nums text-fg-muted; remaining with a true minus (U+2212)Digits that do not jitter.
Current cueaccent-tint + text-fg

Without the script

The <audio controls> is the player: the custom UI is hidden until the script marks the root data-ds-ready, then the native one is hidden and its controls removed. Cues render as text with a static time; their play buttons appear only when ready.

Behaviour

  • One at a time: a module-level set of playing players; play pauses the others unless either is independent.
  • Scrubber: max the duration (duration prop until the file's own), value the time, not overwritten while held. aria-valuetext "1 minute 12 seconds of 4 minutes", rendered in PHP and kept by the script, changed once a second (the PHP and JS spoken/clock mirror each other).
  • Speed: a button stepping through speeds, showing "1.5×", with a visually hidden "Playback speed" before it. A select was the alternative: a button is one press for the common case (faster) and fits compact.
  • Volume: pointer-coarse:hidden with mute; on iOS a page cannot set it.
  • Cues: [data-ds-audio-cue] with data-start / data-end anywhere in the root (the prop's list or the transcript slot). The current one gets aria-current="true" and is scrolled into view in its list; a press on one seeks and plays (not when text is being selected).
  • Events from the root, bubbling: play, pause, ended, timeupdate (at most once a second), each { currentTime, duration }.
  • Media Session: title and artist on play, where supported.
  • Error: the message in a role=status paragraph.

Accessibility

  • Role and name: role=group named by title or label.
  • Play: one button, its name Play / Pause. Mute: aria-pressed.
  • Keyboard:
KeyDoes
SpacePlay / pause, anywhere in the player but a button, link or field (the scrubber included)
Left / Down, Right / Up−5 s / +5 s on the scrubber
Page Down / Page Up−30 s / +30 s
Home / EndStart / end
  • Focus: each control rings itself; the scrubber's and volume's rings are on their wrappers (has-focus-visible:), the inputs being transparent or native.
  • Motion: nothing moves but the light on the bars, which is the content.

Do not

  • Autoplay, or start a player from anything but a press.
  • Announce the time continuously. The valuetext changes once a second and is read when the slider is focused; there is no live region for it.
  • Decode the file in the browser for a waveform. Peaks come from the host.

From the package repo: edit this page on GitHub.

Was this page helpful?