Display
Audio Player
A voice message player with waveform scrubbing, playback rate, lazy loading and slider semantics.
<script>
import { AudioPlayer } from "@codeatlasdev/ui";
</script>
<AudioPlayer src="/voice/42.ogg" peaks={peaks} duration={31} />
The native <audio controls> is unstyled and differs in dark mode and on iOS. This player keeps the <audio> element but draws its own controls. The src is attached on the first play (preload="none"), so a thread with fifty voice notes makes no request until you press play; pass duration so the UI is complete before that. The waveform is a role="slider": drag or click to seek, Arrow keys move 5 seconds, Page Up and Page Down 10, Home and End jump. Starting one player pauses any other.
Voice messages
With peaks, and without waveform data.
Reference #252 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | – | Audio URL, loaded on first play. |
peaks | number[] | – | Waveform amplitudes from 0 to 1, resampled to the width. |
duration | number | – | Seconds, shown before metadata loads. |
rates | number[] | [1, 1.5, 2] | Playback speeds the rate button cycles through. |
preload | 'none' | 'metadata' | 'none' | Load nothing, or only metadata, before the first play. |
label | string | – | Accessible name of the player. |
onplay / onpause / onended / onerror | (e: Event) => void | – | Media events. |