Documentation Index
Fetch the complete documentation index at: https://mintlify.com/afkcodes/react-native-audio-pro/llms.txt
Use this file to discover all available pages before exploring further.
All enums are exported as real TypeScript enum values from react-native-audio-pro. Import them by name — they are available as both types and runtime values, so you can use them in switch statements, comparisons, and serialisation.
import {
AudioProState,
AudioProEventType,
AudioProContentType,
AudioProRepeatMode,
AudioProTriggerSource,
AudioProAmbientEventType,
AudioProErrorCode,
} from 'react-native-audio-pro';
AudioProState
Represents the current state of the audio player. Delivered in every STATE_CHANGED event and also returned by AudioPro.getPlaybackState().
| Value | String | Description |
|---|
AudioProState.IDLE | "IDLE" | No track is loaded. This is the initial state after configure() or after stop(). |
AudioProState.STOPPED | "STOPPED" | A track is loaded and a session is active, but playback has not started (or was explicitly stopped). Position is reset to 0. |
AudioProState.LOADING | "LOADING" | The player is fetching or buffering the audio resource. |
AudioProState.PLAYING | "PLAYING" | Audio is actively playing. |
AudioProState.PAUSED | "PAUSED" | Playback is paused. The track and position are retained. |
AudioProState.ERROR | "ERROR" | An unrecoverable error has occurred. Call AudioPro.stop() to reset. |
AudioPro.addEventListener((event) => {
if (event.type === AudioProEventType.STATE_CHANGED) {
switch (event.payload?.state) {
case AudioProState.PLAYING:
console.log('Now playing');
break;
case AudioProState.PAUSED:
console.log('Paused');
break;
case AudioProState.ERROR:
console.error('Playback failed');
break;
}
}
});
AudioProEventType
Identifies the kind of event delivered to your AudioProEventCallback. Every call to your listener includes one of these values as event.type.
| Value | String | Description |
|---|
AudioProEventType.STATE_CHANGED | "STATE_CHANGED" | The player state changed. Check payload.state for the new AudioProState. |
AudioProEventType.PROGRESS | "PROGRESS" | Periodic playback progress update, fired at the progressIntervalMs interval. |
AudioProEventType.TRACK_ENDED | "TRACK_ENDED" | The current track played to completion. |
AudioProEventType.TRACK_CHANGED | "TRACK_CHANGED" | The active track changed, e.g. auto-advance in the queue. |
AudioProEventType.SEEK_COMPLETE | "SEEK_COMPLETE" | A seek operation finished. Check payload.triggeredBy to determine the source. |
AudioProEventType.PLAYBACK_SPEED_CHANGED | "PLAYBACK_SPEED_CHANGED" | The playback speed was updated. Check payload.speed. |
AudioProEventType.REMOTE_NEXT | "REMOTE_NEXT" | The user pressed the next-track button on the notification or a remote control. |
AudioProEventType.REMOTE_PREV | "REMOTE_PREV" | The user pressed the previous-track button on the notification or a remote control. |
AudioProEventType.PLAYBACK_ERROR | "PLAYBACK_ERROR" | A playback error occurred. Check payload.errorCode and payload.recoverable. |
AudioProEventType.REPEAT_MODE_CHANGED | "REPEAT_MODE_CHANGED" | The repeat mode was updated. |
AudioProEventType.SHUFFLE_MODE_CHANGED | "SHUFFLE_MODE_CHANGED" | Shuffle mode was toggled. |
AudioProEventType.CUSTOM_ACTION | "CUSTOM_ACTION" | A custom notification button was pressed. Check payload.action for the button identifier. |
AudioProEventType.SLEEP_TIMER_COMPLETE | "SLEEP_TIMER_COMPLETE" | The sleep timer expired and playback was stopped. |
AudioProEventType.QUEUE_CHANGED | "QUEUE_CHANGED" | The queue was modified (track added, removed, moved, or cleared). |
AudioProEventType.AUDIO_SESSION_CHANGED | "AUDIO_SESSION_CHANGED" | The audio session ID changed. Use payload.audioSessionId to connect a native equalizer or visualizer. |
Handle REMOTE_NEXT and REMOTE_PREV yourself if you manage queue navigation manually. If you do not handle them, the player’s built-in queue will advance automatically.
AudioProContentType
Declares the type of audio content being played. Passed as contentType inside AudioProConfigureOptions. The platform uses this hint to apply appropriate audio routing and processing.
| Value | String | Description |
|---|
AudioProContentType.MUSIC | "MUSIC" | Music content. This is the default content type. |
AudioProContentType.SPEECH | "SPEECH" | Speech or podcast content. Enables platform-level speech optimisations such as enhanced intelligibility processing. |
AudioPro.configure({
contentType: AudioProContentType.SPEECH,
progressIntervalMs: 5000,
});
AudioProRepeatMode
Controls how the player behaves when a track or the queue ends. Passed as repeatMode inside AudioProConfigureOptions, or changed at runtime via AudioPro.setRepeatMode().
| Value | String | Description |
|---|
AudioProRepeatMode.OFF | "OFF" | No repeat. Playback stops at the end of the queue. |
AudioProRepeatMode.ONE | "ONE" | Repeat the current track indefinitely. |
AudioProRepeatMode.ALL | "ALL" | Repeat the entire queue from the beginning when it ends. |
// Loop a single track
AudioPro.setRepeatMode(AudioProRepeatMode.ONE);
// Loop the whole queue
AudioPro.setRepeatMode(AudioProRepeatMode.ALL);
// Disable looping
AudioPro.setRepeatMode(AudioProRepeatMode.OFF);
AudioProTriggerSource
Identifies who initiated a seek operation. Delivered in AudioProSeekCompletePayload.triggeredBy on every SEEK_COMPLETE event.
| Value | String | Description |
|---|
AudioProTriggerSource.USER | "USER" | The seek was initiated by your application code or a user gesture inside the app. |
AudioProTriggerSource.SYSTEM | "SYSTEM" | The seek was initiated by the operating system or an external remote control (e.g. lock screen scrubber, CarPlay). |
AudioPro.addEventListener((event) => {
if (event.type === AudioProEventType.SEEK_COMPLETE) {
if (event.payload?.triggeredBy === AudioProTriggerSource.SYSTEM) {
// Update your UI to reflect a system-initiated seek
}
}
});
AudioProAmbientEventType
Events emitted by the ambient audio player. Delivered to your AudioProAmbientEventCallback.
| Value | String | Description |
|---|
AudioProAmbientEventType.AMBIENT_TRACK_ENDED | "AMBIENT_TRACK_ENDED" | The ambient track finished playing and loop was false. |
AudioProAmbientEventType.AMBIENT_ERROR | "AMBIENT_ERROR" | An error occurred during ambient playback. The player is automatically cleaned up. Check payload.error for details. |
AudioPro.addAmbientListener((event) => {
if (event.type === AudioProAmbientEventType.AMBIENT_ERROR) {
console.error('Ambient error:', event.payload?.error);
}
});
AudioProErrorCode
Media3-aligned numeric error codes delivered in AudioProPlaybackErrorPayload.errorCode on PLAYBACK_ERROR events. Codes are grouped by category to help you decide whether to retry, surface an error message, or give up.
Network errors (1xxx) are often recoverable — the player may retry automatically. Decoding (2xxx) and DRM (3xxx) errors are typically unrecoverable. Content errors (4xxx) depend on the specific code.
Unknown
| Value | Code | Description |
|---|
AudioProErrorCode.UNKNOWN | 0 | An unclassified error. Inspect payload.cause for more detail. |
Network Errors (1xxx)
Typically recoverable. The player may retry automatically on transient network failures.
| Value | Code | Description |
|---|
AudioProErrorCode.NETWORK_TIMEOUT | 1001 | The network request timed out before data was received. |
AudioProErrorCode.NETWORK_FAILED | 1002 | A general network failure occurred (e.g. no connectivity). |
AudioProErrorCode.TIMEOUT | 1003 | A generic timeout not specific to network fetch. |
AudioProErrorCode.IO_UNSPECIFIED | 1004 | An unspecified I/O error occurred while reading the stream. |
AudioProErrorCode.INVALID_CONTENT_TYPE | 1005 | The server returned an unexpected Content-Type header. |
Decoding Errors (2xxx)
Typically unrecoverable. The audio format cannot be decoded by the current device.
| Value | Code | Description |
|---|
AudioProErrorCode.DECODING_FAILED | 2001 | The audio data could not be decoded. |
AudioProErrorCode.AUDIO_TRACK_INIT_FAILED | 2002 | The audio output track could not be initialised. |
AudioProErrorCode.DECODER_INIT_FAILED | 2003 | The audio decoder failed to initialise. |
AudioProErrorCode.DECODER_QUERY_FAILED | 2004 | Querying the decoder’s capabilities failed. |
AudioProErrorCode.FORMAT_UNSUPPORTED | 2005 | The audio format is not supported by the device. |
AudioProErrorCode.FORMAT_EXCEEDS_CAPABILITIES | 2006 | The audio format is recognised but exceeds the device’s decoding capabilities. |
DRM Errors (3xxx)
Typically unrecoverable. DRM-protected content cannot be played.
| Value | Code | Description |
|---|
AudioProErrorCode.DRM_UNSPECIFIED | 3001 | An unspecified DRM error occurred. |
AudioProErrorCode.DRM_SCHEME_UNSUPPORTED | 3002 | The DRM scheme (e.g. Widevine, PlayReady) is not supported on this device. |
AudioProErrorCode.DRM_PROVISIONING_FAILED | 3003 | Device DRM provisioning failed. |
AudioProErrorCode.DRM_LICENSE_ACQUISITION_FAILED | 3004 | The DRM licence could not be acquired from the licence server. |
AudioProErrorCode.DRM_LICENSE_EXPIRED | 3005 | The DRM licence has expired and must be renewed. |
Content Errors (4xxx)
Recoverability depends on the specific code. Check payload.recoverable.
| Value | Code | Description |
|---|
AudioProErrorCode.CONTENT_NOT_FOUND | 4001 | The audio resource returned a 404 or was otherwise not found. |
AudioProErrorCode.BAD_HTTP_STATUS | 4002 | The server returned an unexpected HTTP status code. |
AudioProErrorCode.CONTAINER_MALFORMED | 4003 | The audio container (e.g. MP4, OGG) is malformed or truncated. |
AudioProErrorCode.MANIFEST_MALFORMED | 4004 | The streaming manifest (e.g. HLS .m3u8, DASH .mpd) is malformed. |
AudioProErrorCode.BEHIND_LIVE_WINDOW | 4005 | The requested position is behind the live window of a live stream. |
AudioPro.addEventListener((event) => {
if (event.type === AudioProEventType.PLAYBACK_ERROR) {
const { errorCode, recoverable, error } = event.payload ?? {};
if (!recoverable) {
if (errorCode === AudioProErrorCode.CONTENT_NOT_FOUND) {
console.error('Track URL is invalid or the file was removed.');
} else if (errorCode && errorCode >= 2000 && errorCode < 3000) {
console.error('Unsupported audio format:', error);
}
}
}
});