Skip to main content

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().
ValueStringDescription
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.
ValueStringDescription
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.
ValueStringDescription
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().
ValueStringDescription
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.
ValueStringDescription
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.
ValueStringDescription
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

ValueCodeDescription
AudioProErrorCode.UNKNOWN0An unclassified error. Inspect payload.cause for more detail.

Network Errors (1xxx)

Typically recoverable. The player may retry automatically on transient network failures.
ValueCodeDescription
AudioProErrorCode.NETWORK_TIMEOUT1001The network request timed out before data was received.
AudioProErrorCode.NETWORK_FAILED1002A general network failure occurred (e.g. no connectivity).
AudioProErrorCode.TIMEOUT1003A generic timeout not specific to network fetch.
AudioProErrorCode.IO_UNSPECIFIED1004An unspecified I/O error occurred while reading the stream.
AudioProErrorCode.INVALID_CONTENT_TYPE1005The server returned an unexpected Content-Type header.

Decoding Errors (2xxx)

Typically unrecoverable. The audio format cannot be decoded by the current device.
ValueCodeDescription
AudioProErrorCode.DECODING_FAILED2001The audio data could not be decoded.
AudioProErrorCode.AUDIO_TRACK_INIT_FAILED2002The audio output track could not be initialised.
AudioProErrorCode.DECODER_INIT_FAILED2003The audio decoder failed to initialise.
AudioProErrorCode.DECODER_QUERY_FAILED2004Querying the decoder’s capabilities failed.
AudioProErrorCode.FORMAT_UNSUPPORTED2005The audio format is not supported by the device.
AudioProErrorCode.FORMAT_EXCEEDS_CAPABILITIES2006The audio format is recognised but exceeds the device’s decoding capabilities.

DRM Errors (3xxx)

Typically unrecoverable. DRM-protected content cannot be played.
ValueCodeDescription
AudioProErrorCode.DRM_UNSPECIFIED3001An unspecified DRM error occurred.
AudioProErrorCode.DRM_SCHEME_UNSUPPORTED3002The DRM scheme (e.g. Widevine, PlayReady) is not supported on this device.
AudioProErrorCode.DRM_PROVISIONING_FAILED3003Device DRM provisioning failed.
AudioProErrorCode.DRM_LICENSE_ACQUISITION_FAILED3004The DRM licence could not be acquired from the licence server.
AudioProErrorCode.DRM_LICENSE_EXPIRED3005The DRM licence has expired and must be renewed.

Content Errors (4xxx)

Recoverability depends on the specific code. Check payload.recoverable.
ValueCodeDescription
AudioProErrorCode.CONTENT_NOT_FOUND4001The audio resource returned a 404 or was otherwise not found.
AudioProErrorCode.BAD_HTTP_STATUS4002The server returned an unexpected HTTP status code.
AudioProErrorCode.CONTAINER_MALFORMED4003The audio container (e.g. MP4, OGG) is malformed or truncated.
AudioProErrorCode.MANIFEST_MALFORMED4004The streaming manifest (e.g. HLS .m3u8, DASH .mpd) is malformed.
AudioProErrorCode.BEHIND_LIVE_WINDOW4005The 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);
      }
    }
  }
});

Build docs developers (and LLMs) love