Skip to content

AudioPlayer

import { AudioPlayer } from '@yarcl/react';
0:00 / 0:00

Pass a URL or a blob URL from a local recording. The player loads metadata, displays elapsed and total time, and lets the listener seek with a slider. It uses an IconButton, Slider and native audio playback. The audio element remains available through ref, and native audio attributes and event handlers pass through to it.

<AudioPlayer src={recordingUrl} onEnded={() => setFinished(true)} />

For a recorder interface, pass a normalized level from 0 to 1 to show an input meter. Its levelLabel names the meter for screen readers.

<AudioPlayer src={recordingUrl} level={inputLevel} levelLabel="Microphone level" />

The play and pause buttons have accessible labels, and the seek slider announces the current time. Use playLabel, pauseLabel and seekLabel to change their labels.

PropTypeDefaultDescription
src requiredstringAudio URL, including a blob URL for a local recording.
classNamestringClass applied to the visible player container.
levelnumberOptional normalized input level from 0 to 1, shown as a meter for recording interfaces.
levelLabelstringAccessible and visible label for the input level meter.
pauseLabelstringAccessible label for the pause button.
playLabelstringAccessible label for the play button.
seekLabelstringAccessible label for the seek slider.
styleCSSPropertiesStyles applied to the visible player container.