Skip to content
Browse docs and components

Audio Player

audio-player

A transport bar for one recording: skip back and forward, play, a seek bar, time, volume and speed. Its ref is a small handle, so a transcript or a chapter list can seek and play it from outside.

Responsive

Install

$npxshadcnadd@forme/audio-player

Adds the component, its registry dependencies, and the token stylesheet you import once.

Examples

6 more ways to put it to work. Install one by name and it lands beside the component, or copy it from the Code tab into your app.

Chapters

An episode with a chapter list: the starts become markers on the waveform, the current chapter fills as it plays, and any chapter seeks and plays.

$npxshadcnadd@forme/audio-player-chapters
Responsive

Keyboard shortcuts

Space, J, K, L, the arrows, M and the number keys, all through the player's handle, with each action confirmed as it happens.

$npxshadcnadd@forme/audio-player-keyboard
Responsive

Plain seek bar

waveform={false}: a line instead of the recording's shape, and no download to draw it — the choice for long files.

$npxshadcnadd@forme/audio-player-plain-seek-bar
Responsive

Volume in a popover

volume="popover": the icon mutes and unmutes on click, and a slider opens above it on hover or focus.

$npxshadcnadd@forme/audio-player-volume-popover
Responsive

Bare

waveform, speed and volume all off: transport, seek and time only, with the device owning the volume.

$npxshadcnadd@forme/audio-player-bare
Responsive

Now playing

A media card that reacts to playback through onPlayingChange, with the player cut to the essentials: a plain seek bar, no speed button and volume in a popover.

$npxshadcnadd@forme/audio-player-now-playing
Responsive

API reference

Read from the source, so it is the API of the file you install. A prop marked * is required.

AudioPlayer

A transport bar for one recording: back, play, forward, the recording's own waveform to scrub, the time, volume and speed. It owns its <audio> element and hands a small handle to its ref, so a transcript, a chapter list or a keyboard shortcut can seek and play it without lifting any state — and onTimeUpdate tells them where playback is.

PropTypeDefaultDescription
src*string | Blob—A URL, or a Blob such as a recording or a synthesised reply.
refRef<AudioPlayerHandle>—
markersreadonly number[]—Start times, in seconds, of the parts of the recording: transcript segments, chapters. The skip buttons step between them and the seek bar marks where each begins. Without them the skip buttons move skip seconds.
skipnumber10Seconds the skip buttons move when there are no markers.
waveformbooleantrueDraws the seek bar as the recording's waveform. The player downloads and decodes the file to find it, which suits clips and voice notes; for long recordings pass precomputed peaks instead, or turn it off.
speedbooleantrueThe speed button, which steps through 1×, 1.25×, 1.5×, 2× and 0.75×.
volume"slider" | "popover" | false"slider"How volume is offered. "slider" puts a mute button and a slider in the bar; "popover" keeps only the button, which mutes on click and shows a slider above it on hover or focus; false leaves volume to the device.
peaksreadonly number[]—Loudness, 0–1, evenly spaced across the recording — as audiowaveform or a server job produces.
onTimeUpdate(seconds: number) => void—Fires as playback moves, every frame while playing, in seconds.
onPlayingChange(playing: boolean) => void—
aria-labelstring—
classNamestring—