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.

The AudioPro object is a static class that exposes every method you need to drive playback in React Native Audio Pro. Import it once and call its methods from anywhere in your app — no instantiation required. All methods delegate directly to the native layer, and mutable state is mirrored in the internal Zustand store so the useAudioPro hook always reflects the latest values.
import { AudioPro } from 'react-native-audio-pro';

Configuration

configure

configure(options: AudioProConfigureOptions): void
Configure the audio player with global settings. Configuration is stored and applied on the next play() call.
options
AudioProConfigureOptions
required
Global configuration object for the player.
options.contentType
AudioProContentType
Type of content being played — 'MUSIC' or 'SPEECH'. Defaults to 'MUSIC'.
options.debug
boolean
Enable verbose debug logging. Defaults to false.
options.debugIncludesProgress
boolean
Include high-frequency progress events in debug logs. Defaults to false.
options.progressIntervalMs
number
How often PROGRESS events fire, in milliseconds. Defaults to 1000.
options.skipIntervalMs
number
Duration used by skip-forward / skip-back notification buttons, in milliseconds. Defaults to 30000.
options.repeatMode
AudioProRepeatMode
Default repeat mode: 'OFF', 'ONE', or 'ALL'.
options.shuffleMode
boolean
Enable shuffle mode by default.
options.maxCacheSize
number
Maximum on-disk cache in bytes. Defaults to 500 MB. Takes effect on first initialization.
options.cacheEnabled
boolean
Enable or disable track caching. Requires a session restart to take full effect. Defaults to true.
options.skipSilence
boolean
Skip silent sections during playback (Android only). Defaults to false.
Returns: void
import { AudioPro, AudioProContentType } from 'react-native-audio-pro';

AudioPro.configure({
  contentType: AudioProContentType.MUSIC,
  progressIntervalMs: 500,
  debug: __DEV__,
  maxCacheSize: 300 * 1024 * 1024, // 300 MB
});

syncFromNative

syncFromNative(): void
Sync JS state from the native player. Call this when the native service survived but the JS bundle was re-loaded — for example, after swiping the app from the recents list and relaunching. It triggers STATE_CHANGED, PROGRESS, and TRACK_CHANGED events so the internal store catches up. Returns: void
// In your root component, after JS re-hydration
useEffect(() => {
  AudioPro.syncFromNative();
}, []);

Playback Control

play

play(options?: AudioProPlayOptions): void
Start or resume playback. Without options, resumes the current queue from where it left off. Pass options to control auto-play behaviour, custom HTTP headers, a start offset, or whether to append a track.
options
AudioProPlayOptions
Optional playback configuration.
options.autoPlay
boolean
Start playing immediately after loading. Defaults to true.
options.headers
AudioProHeaders
Custom HTTP headers for the audio stream (headers.audio) and artwork (headers.artwork).
options.startTimeMs
number
Position in milliseconds to seek to before playback begins.
options.addTrack
boolean
Append the track to the queue instead of replacing it.
Returns: void
// Simple resume
AudioPro.play();

// Start at 30 s with an auth header
AudioPro.play({
  startTimeMs: 30_000,
  headers: { audio: { Authorization: 'Bearer token' } },
});

pause

pause(): void
Pause the current playback. No-op if the player is not in a playing state. Returns: void
AudioPro.pause();

stop

stop(): void
Stop playback and reset the position to zero. Returns: void
AudioPro.stop();

seekTo

seekTo(positionMs: number): void
Seek to an absolute position in the current track. Applies an optimistic UI update immediately while the native seek completes in the background.
positionMs
number
required
Target position in milliseconds. Must be ≥ 0.
Returns: void
// Jump to 1 minute 30 seconds
AudioPro.seekTo(90_000);

seekBy

seekBy(offsetMs: number): void
Seek by a relative offset from the current position. Pass a negative value to seek backwards.
offsetMs
number
required
Offset in milliseconds. Positive = forward, negative = backward.
Returns: void
AudioPro.seekBy(30_000);  // +30 s
AudioPro.seekBy(-10_000); // -10 s

setPlaybackSpeed

setPlaybackSpeed(speed: number): void
Set the playback speed. Values outside the valid range are automatically clamped with a console warning.
speed
number
required
Speed multiplier. Clamped to 0.25 – 2.0. Normal speed is 1.0.
Returns: void
AudioPro.setPlaybackSpeed(1.5); // 1.5×
AudioPro.setPlaybackSpeed(0.8); // 0.8×

setVolume

setVolume(volume: number): void
Set the player volume. Values outside the range are clamped.
volume
number
required
Volume level. Clamped to 0.0 (mute) – 1.0 (full).
Returns: void
AudioPro.setVolume(0.7);

setRepeatMode

setRepeatMode(mode: 'OFF' | 'ONE' | 'ALL'): void
Set the queue repeat behaviour.
mode
'OFF' | 'ONE' | 'ALL'
required
'OFF' — no repeat. 'ONE' — loop the current track. 'ALL' — loop the entire queue.
Returns: void
AudioPro.setRepeatMode('ALL');

setShuffleModeEnabled

setShuffleModeEnabled(enabled: boolean): void
Enable or disable queue shuffle.
enabled
boolean
required
true to enable shuffle, false to disable.
Returns: void
AudioPro.setShuffleModeEnabled(true);

setSkipSilence

setSkipSilence(enabled: boolean): void
Enable or disable automatic silence skipping during playback.
This method is Android only. On iOS it is a no-op.
enabled
boolean
required
true to skip silent sections, false to play them normally.
Returns: void
AudioPro.setSkipSilence(true);

setProgressInterval

setProgressInterval(ms: number): void
Change how often PROGRESS events are emitted without reconfiguring the entire player. Values outside the valid range are clamped.
ms
number
required
Interval in milliseconds. Clamped to 100 – 10000.
Returns: void
// Emit progress every 250 ms for a high-fidelity scrubber
AudioPro.setProgressInterval(250);

Queue Management

addMediaItems

addMediaItems(items: AudioProTrack | AudioProTrack[]): void
Append one or more tracks to the end of the current queue.
items
AudioProTrack | AudioProTrack[]
required
A single track or an array of tracks to append. Invalid items are silently filtered out.
Returns: void
AudioPro.addMediaItems([
  { id: '1', url: 'https://cdn.example.com/track1.mp3', title: 'Track 1', artwork: 'https://cdn.example.com/art1.jpg' },
  { id: '2', url: 'https://cdn.example.com/track2.mp3', title: 'Track 2', artwork: 'https://cdn.example.com/art2.jpg' },
]);

setMediaItems

setMediaItems(items: AudioProTrack[]): void
Replace the entire queue with the provided tracks.
items
AudioProTrack[]
required
The new queue. Invalid items are silently filtered out.
Returns: void
AudioPro.setMediaItems(playlist);
AudioPro.play();

addMediaItemsAt

addMediaItemsAt(index: number, items: AudioProTrack | AudioProTrack[]): void
Insert one or more tracks at a specific queue position.
index
number
required
Zero-based position at which to insert. Items already at this index are shifted right.
items
AudioProTrack | AudioProTrack[]
required
Track or tracks to insert.
Returns: void
// Insert a track at position 2
AudioPro.addMediaItemsAt(2, nextUpTrack);

removeMediaItem

removeMediaItem(index: number): void
Remove a single track at the given index from the queue.
index
number
required
Zero-based index of the track to remove.
Returns: void
AudioPro.removeMediaItem(3);

removeMediaItems

removeMediaItems(fromIndex: number, toIndex: number): void
Remove a contiguous range of tracks. The range is [fromIndex, toIndex) — i.e. fromIndex is inclusive and toIndex is exclusive.
fromIndex
number
required
Start index (inclusive, zero-based).
toIndex
number
required
End index (exclusive).
Returns: void
// Remove tracks at indices 1, 2, 3
AudioPro.removeMediaItems(1, 4);

moveMediaItem

moveMediaItem(currentIndex: number, newIndex: number): void
Move a track from one queue position to another.
currentIndex
number
required
Current zero-based index of the track to move.
newIndex
number
required
Target zero-based index.
Returns: void
// Drag-and-drop reorder callback
AudioPro.moveMediaItem(fromIndex, toIndex);

clearMediaItems

clearMediaItems(): void
Remove all tracks from the queue. Returns: void
AudioPro.clearMediaItems();

getMediaItems

getMediaItems(): Promise<AudioProTrack[]>
Retrieve the full list of tracks currently in the queue. Returns: Promise<AudioProTrack[]> — resolves to the current queue.
const queue = await AudioPro.getMediaItems();
console.log(`Queue has ${queue.length} tracks`);

seekToMediaItem

seekToMediaItem(index: number, positionMs?: number): void
Jump to a specific track in the queue, optionally seeking to a position within it.
index
number
required
Zero-based queue index to jump to.
positionMs
number
Position in milliseconds to seek to once the track is ready.
Returns: void
// Jump to track 4 at the 45-second mark
AudioPro.seekToMediaItem(4, 45_000);

seekToNextMediaItem

seekToNextMediaItem(): void
Advance to the next track in the queue. Returns: void
AudioPro.seekToNextMediaItem();

seekToPreviousMediaItem

seekToPreviousMediaItem(): void
Go back to the previous track in the queue. Returns: void
AudioPro.seekToPreviousMediaItem();

updateTrack

updateTrack(index: number, track: AudioProTrack): void
Replace the metadata (or URL) for an existing queue entry without rebuilding the whole queue. Useful for refreshing expiring signed URLs.
index
number
required
Zero-based index of the track to update.
track
AudioProTrack
required
The new track object. Must pass validation; invalid tracks are rejected with a warning.
Returns: void
// Refresh an expiring stream URL before it expires
AudioPro.updateTrack(currentIndex, { ...currentTrack, url: freshSignedUrl });

Audio Effects

The following audio-effect methods are Android only. On iOS they are no-ops.

setEqualizer

setEqualizer(gains: number[]): void
Apply gain values to each equalizer band. Gains are typically expressed in decibels, with a usual range of -10 to +10. Pass one value per band, ordered from 31 Hz to 16 kHz (10 bands total). See EQUALIZER_BANDS for the full band list.
gains
number[]
required
Array of 10 dB gain values, one per EQ band ordered from 31 Hz to 16 kHz.
Returns: void
// Boost bass and treble slightly (10 bands: 31Hz–16kHz)
AudioPro.setEqualizer([4, 2, 0, 0, 0, 0, 0, 2, 3, 3]);

setBassBoost

setBassBoost(strength: number): void
Apply a bass boost effect to the audio output.
strength
number
required
Bass boost intensity, from 0 (off) to 1000 (maximum).
Returns: void
AudioPro.setBassBoost(500); // medium bass boost

Notification

setNotificationButtons

setNotificationButtons(buttons: AudioProNotificationButton[]): void
Configure which action buttons appear on the media notification and lock screen controls. Play/Pause is always included. Changes take effect on the next playback session.
buttons
AudioProNotificationButton[]
required
Ordered array of button identifiers to display. Maximum 4 additional buttons (5 total including Play/Pause). Valid values: 'PLAY', 'PAUSE', 'PREV', 'NEXT', 'LIKE', 'DISLIKE', 'SAVE', 'BOOKMARK', 'REWIND_30', 'FORWARD_30'.
Returns: void
AudioPro.setNotificationButtons(['PREV', 'NEXT']);

updateNotificationState

updateNotificationState(options: { liked?: boolean; disliked?: boolean; bookmarked?: boolean }): void
Refresh the visual state of stateful notification buttons (LIKE, DISLIKE, BOOKMARK) to reflect app-side changes — for example, when a user toggles a favourite.
options.liked
boolean
Whether the current track is marked as liked.
options.disliked
boolean
Whether the current track is marked as disliked.
options.bookmarked
boolean
Whether the current track is bookmarked.
Returns: void
// After user taps the like button
AudioPro.updateNotificationState({ liked: true });

Events

addEventListener

addEventListener(callback: AudioProEventCallback): EmitterSubscription
Subscribe to all player events. Returns a subscription object — call .remove() on it to unsubscribe.
callback
AudioProEventCallback
required
Function called for every player event. Receives an AudioProEvent with type, track, and optional payload.
Returns: EmitterSubscription
const subscription = AudioPro.addEventListener((event) => {
  switch (event.type) {
    case 'STATE_CHANGED':
      console.log('State:', event.payload?.state);
      break;
    case 'TRACK_CHANGED':
      console.log('Now playing:', event.track?.title);
      break;
    case 'PLAYBACK_ERROR':
      console.error('Error:', event.payload?.error);
      break;
  }
});

// Later — clean up
subscription.remove();
Event types are exported as the AudioProEventType enum for exhaustive switch statements and autocompletion.

addAmbientListener

addAmbientListener(callback: AudioProAmbientEventCallback): EmitterSubscription
Subscribe to ambient audio events. Returns a subscription object.
callback
AudioProAmbientEventCallback
required
Function called for ambient events. Receives an AudioProAmbientEvent with type ('AMBIENT_TRACK_ENDED' or 'AMBIENT_ERROR') and optional payload.
Returns: EmitterSubscription
const sub = AudioPro.addAmbientListener((event) => {
  if (event.type === 'AMBIENT_TRACK_ENDED') {
    // Loop manually or trigger next ambient track
  }
});

sub.remove(); // when done

Ambient Audio

Ambient audio plays independently of the main queue — useful for background soundscapes, nature sounds, or meditation backgrounds layered beneath a primary track.

ambientPlay

ambientPlay(options: AmbientAudioPlayOptions): void
Start playing an ambient audio file.
options.url
string
required
URL of the audio file. Supports http://, https://, and file:// schemes.
options.loop
boolean
Whether to loop the ambient audio. Defaults to true.
Returns: void
AudioPro.ambientPlay({
  url: 'https://cdn.example.com/rain.mp3',
  loop: true,
});

ambientStop

ambientStop(): void
Stop ambient audio playback and release the resource. Returns: void
AudioPro.ambientStop();

ambientPause

ambientPause(): void
Pause ambient playback. No-op if already paused or no ambient track is loaded. Returns: void
AudioPro.ambientPause();

ambientResume

ambientResume(): void
Resume a paused ambient track. No-op if already playing or no ambient track is loaded. Returns: void
AudioPro.ambientResume();

ambientSeekTo

ambientSeekTo(positionMs: number): void
Seek to a specific position in the ambient track.
positionMs
number
required
Target position in milliseconds.
Returns: void
AudioPro.ambientSeekTo(10_000); // seek to 10 s

ambientSetVolume

ambientSetVolume(volume: number): void
Set the volume of the ambient audio layer independently of the main player volume.
volume
number
required
Volume level clamped to 0.0 (mute) – 1.0 (full).
Returns: void
// Duck ambient audio when main track starts
AudioPro.ambientSetVolume(0.3);

Cache

getCacheSize

getCacheSize(): Promise<number>
Return the total size of the on-disk audio cache. Returns: Promise<number> — resolves to the cache size in bytes.
const bytes = await AudioPro.getCacheSize();
const mb = (bytes / (1024 * 1024)).toFixed(1);
console.log(`Cache size: ${mb} MB`);

clearCache

clearCache(): Promise<boolean>
Delete all cached audio files. Returns: Promise<boolean> — resolves to true when the cache was cleared successfully.
const cleared = await AudioPro.clearCache();
if (cleared) {
  console.log('Cache cleared');
}

Sleep Timer

startSleepTimer

startSleepTimer(seconds: number): void
Pause playback automatically after a set duration. Fires a SLEEP_TIMER_COMPLETE event when triggered.
seconds
number
required
Number of seconds to wait before pausing.
Returns: void
// Pause after 30 minutes
AudioPro.startSleepTimer(30 * 60);

cancelSleepTimer

cancelSleepTimer(): void
Cancel an active sleep timer. Returns: void
AudioPro.cancelSleepTimer();

State Getters

These methods read directly from the internal store and return synchronously — no async/await required.
For reactive state in React components, use the useAudioPro hook instead of calling these in render. Reserve state getters for callbacks, event handlers, and non-React code.

getTimings

getTimings(): { position: number; duration: number }
Return the current playback position and total track duration. Returns: { position: number; duration: number } — both values in milliseconds.
const { position, duration } = AudioPro.getTimings();

getPlaybackState

getPlaybackState(): AudioProState
Return the current playback state. Returns: AudioProState — one of 'IDLE', 'STOPPED', 'LOADING', 'PLAYING', 'PAUSED', or 'ERROR'.
if (AudioPro.getPlaybackState() === 'PLAYING') {
  AudioPro.pause();
}

getCurrentMediaItem

getCurrentMediaItem(): AudioProTrack | null
Return the currently active track, or null if the queue is empty. Returns: AudioProTrack | null
const track = AudioPro.getCurrentMediaItem();
console.log(track?.title);

getCurrentMediaItemIndex

getCurrentMediaItemIndex(): number
Return the zero-based index of the currently active track in the queue, or -1 if no track is active. Returns: number
const index = AudioPro.getCurrentMediaItemIndex();

getPlaybackSpeed

getPlaybackSpeed(): number
Return the current playback speed multiplier. Returns: number — between 0.25 and 2.0.
const speed = AudioPro.getPlaybackSpeed(); // e.g. 1.5

getVolume

getVolume(): number
Return the current player volume. Returns: number — between 0.0 and 1.0.
const vol = AudioPro.getVolume();

getError

getError(): AudioProPlaybackErrorPayload | null
Return the most recent playback error, or null if the last operation succeeded. Returns: AudioProPlaybackErrorPayload | null
const err = AudioPro.getError();
if (err) {
  console.error(err.error, err.errorCode);
}

getProgressInterval

getProgressInterval(): number
Return the currently configured progress event interval. Returns: number — interval in milliseconds.
const interval = AudioPro.getProgressInterval(); // e.g. 1000

Build docs developers (and LLMs) love