expo-audio
Version: 55.0.6 A cross-platform audio library for React Native and Expo apps. Provides playback and recording capabilities with support for various audio formats.Installation
Usage
API Reference
AudioPlayer
The main class for playing audio files.constructor
Creates a new audio player instanceParameters:
source: Audio source (require() or URI string)
() => Promise<void>
Starts or resumes playback
() => Promise<void>
Pauses playback
() => Promise<void>
Stops playback and resets position
(position: number) => Promise<void>
Seeks to specified position in milliseconds
(volume: number) => Promise<void>
Sets playback volume (0.0 to 1.0)
() => Promise<void>
Releases resources associated with the player
AudioRecorder
constructor
Creates a new audio recorder instance
() => Promise<void>
Starts recording audio
() => Promise<string>
Stops recording and returns the URI of the recorded file
Permissions
() => Promise<PermissionResponse>
Asks the user to grant permissions for audio recording
() => Promise<PermissionResponse>
Checks the current recording permission status
Examples
Audio Player with Controls
Audio Recorder
Platform Support
Permissions
iOS
Add toapp.json:
Android
Permissions are automatically added toAndroidManifest.xml:
RECORD_AUDIO- for recording audio