Background playback is built into React Native Audio Pro — once you complete the platform setup below, audio continues when the screen locks or the app moves to the background. This guide covers the required configuration for both iOS and Android, lock screen remote control events, and how to customize the notification with your own action buttons.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.
iOS Setup
Enable Background Modes in Xcode
Open your project in Xcode, select your app Target, then go to Signing & Capabilities. Click + Capability, search for Background Modes, and add it. In the Background Modes section that appears, check Audio, AirPlay, and Picture in Picture.
AVFoundation and MPNowPlayingInfoCenter are automatic
React Native Audio Pro uses
AVFoundation for audio playback and MPNowPlayingInfoCenter for the lock screen Now Playing widget. No additional code is required — track metadata (title, artist, artwork, position, duration) is pushed to the system automatically whenever you call play().Android Setup
Set compileSdkVersion and targetSdkVersion to 35
Open
android/build.gradle and confirm both SDK version values are set to 35:Media3 session is automatic
React Native Audio Pro uses Android Media3 for its media session and notification controls. The foreground service and notification channel are managed internally — no extra entries in
AndroidManifest.xml are required. The media notification appears automatically when playback begins.Lock Screen Controls
When the user taps the next or previous buttons on the lock screen (or in the notification), the player emitsREMOTE_NEXT and REMOTE_PREV events. Use addEventListener to handle them and advance the queue or trigger any other logic in your app.
Custom Notification Buttons
You can replace the default notification layout with a custom set of action buttons usingsetNotificationButtons. Call this before or after configure() — changes take effect on the next playback session.
Play and Pause are always included in the notification automatically — you do not need to add them to the array. The maximum total button count (including Play/Pause) is 5.
| Button | Description |
|---|---|
PLAY | Play button |
PAUSE | Pause button |
PREV | Previous track |
NEXT | Next track |
LIKE | Like / heart icon |
DISLIKE | Dislike / thumbs down icon |
SAVE | Save to playlist |
BOOKMARK | Bookmark icon |
REWIND_30 | Rewind 30 seconds |
FORWARD_30 | Forward 30 seconds |
Listening for Custom Button Presses
When a custom action button is tapped, the player emits aCUSTOM_ACTION event. The event.payload.action field contains the button name as a string ('LIKE', 'BOOKMARK', etc.).
Notification State
After handling aCUSTOM_ACTION event you can update the icon state of togglable buttons (liked, disliked, bookmarked) by calling updateNotificationState. This keeps the notification in sync with your app’s state.
updateNotificationState accepts an object with optional boolean fields:
| Field | Type | Description |
|---|---|---|
liked | boolean | Filled heart icon when true |
disliked | boolean | Active dislike icon when true |
bookmarked | boolean | Filled bookmark icon when true |