This project is now archived and no longer maintained. Thank you.
This project is now archived and no longer maintained. Thank you.
[!WARNING]
⚠️ Archived / No Longer Maintained
Thank you for using
react-native-audio-proand for contributing feedback, fixes, and ideas. This project is now archived and no longer maintained. Feel free to fork this repository if you need changes for your own project.
Modern, background-capable audio playback for React Native — built for podcasts, audiobooks, and long-form media. Works out of the box with background playback, lock screen controls, and clean hooks-based state. Under the hood: Android uses Media3 (not old-school ExoPlayer), giving you up-to-date media session support without any of the legacy baggage. iOS uses AVFoundation, Apple's native audio engine for professional-grade media playback. Supports static remote files on iOS and Android.
These are fully supported, maintained features and the foundation of the library:
play, pause, resume, stop, etc.React Native Audio Pro also includes a few optional capabilities that support more advanced or specialized use cases. These are included in the library but may not receive the same level of maintenance priority as the core feature set.
file:// paths (e.g. using react-native-fs)autoPlay and startTimeMs. For stop-at logic, use progress events in your appnpm install react-native-audio-proor
yarn add react-native-audio-proInstall the CocoaPods dependencies:
npx pod-installNote: This library requires Android 8.0 (API 26)+ and
compileSdkVersion = 35andtargetSdkVersion = 35to support the latest Media3 features. While Media3 APIs are supported from API 21+, our focus is on API 28+.
In android/build.gradle:
buildscript {
ext {
minSdkVersion = 26
compileSdkVersion = 35
targetSdkVersion = 35
// ...
}
}Note: React Native Audio Pro requires a development build when using Expo, as it contains native code that cannot run in Expo Go.
npx expo install expo-build-propertiesapp.json:{
"expo": {
"ios": {
"infoPlist": {
"UIBackgroundModes": ["audio"]
}
}
}
}app.json:plugins: [
[
"expo-build-properties",
{
"android": {
"minSdkVersion": 26,
"compileSdkVersion": 35,
"targetSdkVersion": 35,
},
},
],
]React Native Audio Pro supports various audio file formats including MP3, AAC, and WAV, delivered over HTTPS.
| Method | Description | Return Value |
|---|---|---|
| play(track: AudioProTrack, options?: AudioProPlayOptions) | Loads and starts playing the specified track. | void |
| pause() | Pauses the current playback. | void |
| resume() | Resumes playback if paused. | void |
| stop() | Stops playback and resets position to 0 while keeping the current track loaded; use clear() to unload it. |
void |
| clear() | Fully resets the player to the IDLE state and tears down the native player instance. |
void |
| seekTo(positionMs: number) | Seeks to a specific position (in milliseconds). | void |
| seekForward(amountMs?: number) | Seeks forward by the specified milliseconds (default: 30 seconds). | void |
| seekBack(amountMs?: number) | Seeks backward by the specified milliseconds (default: 30 seconds). | void |
| configure(options: AudioProSetupOptions) | Sets playback options. Takes effect the next time play() is called. |
void |
| setProgressInterval(ms: number) | Sets the PROGRESS event frequency (in ms). Takes effect the next time play() is called. |
void |
| getProgressInterval() | Returns the current progress interval in milliseconds. | number |
| getTimings() | Returns the current playback position and total duration in milliseconds. | { position: number, duration: number } |
| getState() | Returns the current playback state. | AudioProState |
| getPlayingTrack() | Returns the current track, or null if none is loaded. |
AudioProTrack | null |
| setPlaybackSpeed(speed: number) | Sets the playback speed rate (0.25 to 2.0). Normal speed is 1.0. |
void |
| getPlaybackSpeed() | Returns the current playback speed rate. | number |
| setVolume(volume: number) | Sets the playback volume from 0.0 to 1.0. Does not affect the system volume. |
void |
| getVolume() | Returns the current relative volume (0.0 to 1.0). |
number |
| getError() | Returns the last error that occurred, or null if no error has occurred. |
AudioProPlaybackErrorPayload | null |
The useAudioPro hook provides real-time access to the audio player state within your React components.
const { state, position, duration, playingTrack, playbackSpeed, volume, error } = useAudioPro();To subscribe to only the specific piece of state your component needs (and avoid unnecessary re-renders), you can pass a selector function:
// Only re-renders when the playing track changes
const playingTrack = useAudioPro((s) => s.playingTrack);| Value | Description | Type |
|---|---|---|
| state | Current playback state of the audio player. | AudioProState |
| position | Current playback position in milliseconds. | number |
| duration | Total duration of the current track in milliseconds. | number |
| playingTrack | Currently playing track object, or null if no track is loaded. | AudioProTrack | null |
| playbackSpeed | Current playback speed rate (0.25 to 2.0). | number |
| volume | Current playback volume (0.0 to 1.0). | number |
| error | Last error that occurred, or null if no error has occurred. | AudioProPlaybackErrorPayload | null |
| Method | Description | Return Value |
|---|---|---|
| addEventListener(callback: AudioProEventCallback) | Listens for playback events (e.g., state changes, track ended, errors, progress). | EmitterSubscription — call .remove() to unsubscribe. |
| State | Description |
|---|---|
IDLE |
The default state on app launch. Represents a player with no loaded track and fully cleared media sessions. |
STOPPED |
Playback is stopped but the track remains loaded. Position is reset to 0, and media session controls remain visible. |
LOADING |
A track is being loaded or buffered and is not yet ready for playback. |
PLAYING |
A track is currently playing. |
PAUSED |
Playback is paused at the current position. |
ERROR |
An error occurred during playback. Check AudioPro.getError() for details. |
| Event | Description |
|---|---|
STATE_CHANGED |
Emitted when the player's state changes (e.g., from LOADING to PLAYING). |
PROGRESS |
Emitted approximately once per second during playback with current position and duration. |
TRACK_ENDED |
Emitted when a track completes playback naturally. |
SEEK_COMPLETE |
Emitted when a seek operation completes. Payload includes triggeredBy (USER or SYSTEM). |
PLAYBACK_SPEED_CHANGED |
Emitted when the playback speed is changed. |
REMOTE_NEXT |
Emitted when the user presses the "Next" button on lock screen controls. |
REMOTE_PREV |
Emitted when the user presses the "Previous" button on lock screen controls. |
PLAYBACK_ERROR |
Emitted when a playback error occurs. |
| Type | Description |
|---|---|
MUSIC |
Optimized for music playback. Use for songs or music-heavy audio content. This is the default. |
SPEECH |
Optimized for spoken word content. Use for podcasts, audiobooks, or speech-heavy content. |
Ambient-specific event enums are documented in the Ambient Audio Guide.
Both iOS and Android support lock screen and notification controls for play/pause, seek, and track navigation (next/previous).
Configuration options:
AudioPro.configure({
contentType: AudioProContentType.MUSIC,
showNextPrevControls: true, // Hide next/previous buttons
showSkipControls: false, // Show skip/seek forward/back buttons (default: true)
skipIntervalMs: 30000, // Number of milliseconds for sNo open issues yet, or sync has not completed.