WaveformAudioPlayer
An audio player with a bar waveform you can click to seek.
0:00 / 0:00
0:00 / 0:00
0:00 / 0:00
0:00 / 0:00
0:00 / 0:00
0:00
0:00
In context
0:00 / 0:00
Trailing action, playback state, error
0:00 / 0:00
0:00 / 0:00
0:00 / 0:00
Couldn’t play this recording. Check your connection and tap play to try again.
Narration files are not bundled with this site, so playback itself needs real audio; the bar, state and error handling are live.
0:00 / 0:00
0:00 / 0:00
Props
| Prop | Type | Required | Default |
|---|---|---|---|
src | string | Yes | — |
barCount | number | undefined | No | 48 |
skipSeconds | number | undefined | No | 15 |
trailingAction | ReactNode | No | — |
autoPlay | boolean | undefined | No | false |
onPlayBlocked | (() => void) | undefined | No | — |
playing | boolean | undefined | No | — |
onPlayingChange | ((playing: boolean) => void) | undefined | No | — |
onEnded | (() => void) | undefined | No | — |
onTimeUpdate | ((currentTime: number, duration: number) => void) | undefined | No | — |
error | ReactNode | No | — |
onRetry | (() => void) | undefined | No | — |
loading | boolean | undefined | No | — |
tone | "default" | "onDark" | undefined | No | default |
audioRef | Ref<HTMLAudioElement> | undefined | No | — |
crossOrigin | "" | "anonymous" | "use-credentials" | undefined | No | — |
controls | "text" | "icons" | undefined | No | text |
size | "default" | "compact" | undefined | No | default |
appearance | "track" | "default" | "card" | undefined | No | default |
barHeights | number[] | undefined | No | — |
playIcon | ReactNode | No | — |
pauseIcon | ReactNode | No | — |
Waveform
Bar heights are seeded from src, so the same audio always shows the same bars; there is no real amplitude analysis.
data-rebar-* attributes
data-rebar-component="waveform-audio-player"; parts include play-button, skip-back, skip-forward, waveform, bar (with data-played once passed), time.
Migrating to Ant Design
Not codemod-covered. AntD has no audio player; use a dedicated library or a native <audio controls> if you do not need the waveform.
Track appearance
appearance="track" is the plain mobile player: a bare round play/pause glyph, a thin seek rail with a progress fill, and m:ss / m:ss. There are no bars and no skip buttons; the rail is still the role="slider" named Seek. Set --rebar-waveform-track-fill, -rail, -glyph-size, -gap, -height, -rail-height, -time-size, -time-opacity and --rebar-waveform-glyph-ink to match a brand.
Card appearance
appearance="card" draws the app player: a raised rounded card, a round play button (playIcon and pauseIcon swap the glyph), the elapsed time, a short bar waveform (barHeights gives one percent per bar; a bar counts as played while its index over the count is at most the progress) and the total time. Skip buttons are not drawn. Set --rebar-waveform-card-background, -radius, -padding, -shadow, -gap, -play-size, -play-background, -play-color, -time-*, -height, -bar, -bar-played to match a brand.
Icon controls, compact size, audioRef
controls="icons" draws round glyph buttons (play, pause, replay, skip back/forward with the seconds) instead of the labelled text buttons; each keeps its accessible name. size="compact" tightens the bar for lists and cards. audioRef gives you the underlying <audio> element (object or callback ref) and crossOrigin is forwarded to it. The error message uses a danger tone mixed toward the text colour, at least 6:1 on the page and tints in light and dark, and a lighter one on tone="onDark".
<WaveformAudioPlayer src={url} controls="icons" size="compact" audioRef={audio} crossOrigin="anonymous" />Tokens
Custom properties, set on the component or any ancestor. The default is what applies when one is unset. 30 of 30 were added in 1.1.0 and are marked.
| Property | Default | |
|---|---|---|
--rebar-waveform-card-background | var(--rebar-color-bg-raised, #fff) | 1.1 |
--rebar-waveform-card-bar | rgba(10, 11, 22, 0.15) | 1.1 |
--rebar-waveform-card-bar-gap | 2px | 1.1 |
--rebar-waveform-card-bar-played | var(--rebar-color-primary, #0066cc) | 1.1 |
--rebar-waveform-card-bar-radius | 2px | 1.1 |
--rebar-waveform-card-gap | 10px | 1.1 |
--rebar-waveform-card-height | 32px | 1.1 |
--rebar-waveform-card-padding | 14px 20px 14px 16px | 1.1 |
--rebar-waveform-card-play-background | var(--rebar-color-bg-inverse, #12142b) | 1.1 |
--rebar-waveform-card-play-color | var(--rebar-color-text-inverse, #fdfaf5) | 1.1 |
--rebar-waveform-card-play-font-size | 18px | 1.1 |
--rebar-waveform-card-play-size | 44px | 1.1 |
--rebar-waveform-card-radius | 20px | 1.1 |
--rebar-waveform-card-shadow | 0 8px 24px rgba(10, 11, 22, 0.08) | 1.1 |
--rebar-waveform-card-time-color | var(--rebar-color-text-primary, inherit) | 1.1 |
--rebar-waveform-card-time-line-height | normal | 1.1 |
--rebar-waveform-card-time-opacity | 0.55 | 1.1 |
--rebar-waveform-card-time-size | 12px | 1.1 |
--rebar-waveform-track-button-font-size | 13.3333px | 1.1 |
--rebar-waveform-track-button-line-height | 1 | 1.1 |
--rebar-waveform-track-color | inherit | 1.1 |
--rebar-waveform-track-fill | var(--rebar-color-primary, #0066cc) | 1.1 |
--rebar-waveform-track-gap | 12px | 1.1 |
--rebar-waveform-track-glyph-size | 44px | 1.1 |
--rebar-waveform-track-height | 22px | 1.1 |
--rebar-waveform-track-rail | color-mix(in srgb, currentColor 25%, transparent) | 1.1 |
--rebar-waveform-track-rail-height | 4px | 1.1 |
--rebar-waveform-track-time-line-height | inherit | 1.1 |
--rebar-waveform-track-time-opacity | 0.85 | 1.1 |
--rebar-waveform-track-time-size | 12px | 1.1 |