This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Audio (expo-av)
A library that provides an API to implement audio playback and recording in apps.
Deprecated: The
Audiocomponent fromexpo-av, which is documented on this page, has now been deprecated and replaced by an improved version inexpo-audio. Learn aboutexpo-audio.
Audio from expo-av allows you to implement audio playback and recording in your app.
Note that audio automatically stops if headphones/bluetooth audio devices are disconnected.
See the playlist example app for an example on the media playback API, and the recording example app for an example of the recording API.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Playing sounds
Recording sounds
Playing or recording audio in background iOS
On iOS, audio playback and recording in background is only available in standalone apps, and it requires some extra configuration.
On iOS, each background feature requires a special key in UIBackgroundModes array in your Info.plist file.
In standalone apps this array is empty by default, so to use background features you will need to add appropriate keys to your app.json configuration.
See an example of app.json that enables audio playback in background:
{ "expo": { ... "ios": { ... "infoPlist": { ... "UIBackgroundModes": [ "audio" ] } } } }
Notes on web usage
- A MediaRecorder issue on Chrome produces WebM files missing the duration metadata. See the open Chromium issue.
- MediaRecorder encoding options and other configurations are inconsistent across browsers, utilizing a Polyfill such as kbumsik/opus-media-recorder or ai/audio-recorder-polyfill in your application will improve your experience. Any options passed to
prepareToRecordAsyncwill be passed directly to the MediaRecorder API and as such the polyfill. - Web browsers require sites to be served securely for them to listen to a mic. See MediaDevices
getUserMedia()security for more details.
API
import { Audio } from 'expo-av';
No API data file found, sorry!
Unified API
The rest of the API on the Sound.Audio is the same as the API for Video component ref. See the AV documentation for more information.