Audio Player

Plays a sound with a play button, a seek bar, skip buttons and a speed control, the same on every platform.
Stable
Web
iOS
Android
@advui/core
Source

Audio player

Radio message: flood safetyCommunity radio · Ayeyarwady

Installation

pnpm
pnpm add @advui/core
npm
npm install @advui/core

Usage

import { AudioPlayer } from '@advui/core'

<AudioPlayer src="https://example.org/radio/flood-safety.mp3" title="Flood safety" subtitle="Community radio" />

// iOS and Android: register an engine once at app start (see Platform notes).
import { setAudioEngine } from '@advui/core'
import { createAudioPlayer } from 'expo-audio'

Examples

Voice message

An icon, and no skip or speed buttons.
Voice message from Daw Hla

API reference

AudioPlayer

Also takes View props (`maxWidth`…) for the frame.
PropTypeDefaultDescription
src requiredstring | number—A URL, or `require()` of a bundled file on native.
title requiredstring—Shown as the heading and names the player.
subtitlestring—A second line: speaker, date, length.
artworkReactNode—An image or icon before the title.
skipnumber10Seconds moved by the skip buttons; 0 hides them.
ratesnumber[][1, 1.25, 1.5, 2]Speeds the speed button cycles through. One speed hides the button.
autoPlaybooleanfalseStart at once.
loopbooleanfalsePlay again at the end.
onPlay() => void—Called when playback starts.
onPause() => void—Called when playback pauses.
onEnded() => void—Called when playback reaches the end (not while looping).
labelsPartial<AudioPlayerLabels>—Button names, seek text and the error, for translation.

setAudioEngine

Registers the native engine: `(source, onStatus) => AudioEngine`, where the engine has `play`, `pause`, `seek(seconds)`, `setRate`, `setLoop` and `release`, and reports `AudioStatus` changes through `onStatus`. Call it once at app start.

Accessibility

  • On web the player is a group named by its title, so "Play" and "Seek" are read in context. iOS and Android read no group names, and TalkBack made a named frame one stop that caught touches meant for its buttons, so there the frame is unnamed.
  • The play button’s name follows the state ("Play" / "Pause"). The seek bar is a slider whose value reads "1:05 of 3:20"; the time labels beside it are hidden to avoid reading them twice.
  • The speed button says its value ("Playback speed, 1.5×"). Skip buttons say how far they move.
  • If the sound cannot be played, the controls are disabled and a message replaces the subtitle.
  • Provide a transcript nearby for speech: people who cannot hear it, or cannot play sound, need one (WCAG 1.2.1).
Keyboard interactions
KeyAction
TabPlay, speed, skip back, seek bar, skip forward.
Enter / SpacePress the focused button.
Arrow keysMove the seek bar by one second (Page Up / Down: bigger steps).

Responsive behavior

Fills its container’s width; set maxWidth to limit it.

Platform notes

Web
Uses an Audio element that is not added to the page, with preload="metadata" so the length shows before playing.
iOS
Uses the engine registered with setAudioEngine, e.g. a wrapper around expo-audio (see the Expo playground’s _layout.tsx). Without one the controls are disabled and it warns in development.
Android
Same as iOS.
Since v0.6.0Last updated Nov 2, 2026Edit this page on GitHub