### Install iOS Dependencies with CocoaPods Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/installation.mdx Navigate to the ios directory and run pod install to set up native iOS dependencies. ```bash cd ios && pod install ``` -------------------------------- ### Install react-native-nitro-player with bun Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/installation.mdx Use this command to install the player and its dependencies using bun. ```bash bun add react-native-nitro-player react-native-nitro-modules ``` -------------------------------- ### Install React Native Nitro Player Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Install the library using npm or yarn. ```bash npm install react-native-nitro-player ``` ```bash yarn add react-native-nitro-player ``` -------------------------------- ### Install react-native-nitro-player Source: https://context7.com/riteshshukla04/react-native-nitro-player/llms.txt Install the package and its peer dependency. For iOS, run `pod install` afterwards. Android requires no extra steps. ```bash # npm npm install react-native-nitro-player react-native-nitro-modules # yarn yarn add react-native-nitro-player react-native-nitro-modules # bun bun add react-native-nitro-player react-native-nitro-modules ``` ```bash # iOS only cd ios && pod install ``` -------------------------------- ### Install react-native-nitro-player with npm Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/installation.mdx Use this command to install the player and its dependencies using npm. ```bash npm install react-native-nitro-player react-native-nitro-modules ``` -------------------------------- ### Install react-native-nitro-player with yarn Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/installation.mdx Use this command to install the player and its dependencies using yarn. ```bash yarn add react-native-nitro-player react-native-nitro-modules ``` -------------------------------- ### Install CocoaPods Dependencies Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/example/README.md Before running the iOS app, install CocoaPods dependencies. Run 'bundle install' once to install the bundler, then 'bundle exec pod install' after updating native dependencies. ```sh bundle install ``` ```sh bundle exec pod install ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/example/README.md Run this command from the root of your React Native project to start the Metro dev server. This is essential for the development workflow. ```sh # Using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Import necessary modules in React Native Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/example/src/README.md Import screens, data, hooks, and styles from the example app. Ensure the 'react-native-nitro-player' package is installed for hooks. ```typescript import PlayerScreen from './src/screens/PlayerScreen'; import { sampleTracks1 } from './src/data/sampleTracks'; import { usePlaylist } from 'react-native-nitro-player'; import { colors, commonStyles, spacing } from './src/styles/theme'; ``` -------------------------------- ### Install Peer Dependencies Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Ensure react-native-nitro-modules is installed as a peer dependency. ```bash npm install react-native-nitro-modules ``` -------------------------------- ### Play Audio Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Resume or start audio playback. Ensure the player is configured before calling. ```typescript await TrackPlayer.play(); ``` -------------------------------- ### Get Effective URL Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Determines the playback URL, prioritizing local downloads. ```APIDOC ## getEffectiveUrl(track) ### Description Get the URL to use for playback based on the current playback source preference. Returns local path if downloaded and preference is 'auto'/'download', otherwise returns the track's original URL. ### Method ```typescript DownloadManager.getEffectiveUrl(track: Track) ``` ### Parameters #### Path Parameters - **track** (Track) - Required - The track object for which to determine the playback URL. ### Response #### Success Response - **Promise** - A promise that resolves with the effective playback URL. ### Request Example ```typescript const url = await DownloadManager.getEffectiveUrl(track); ``` ``` -------------------------------- ### Build and Run iOS App Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/example/README.md Use this command to build and run the iOS application. Ensure Metro is running and CocoaPods dependencies are installed. ```sh # Using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Create and Manage Playlists with PlayerQueue Source: https://context7.com/riteshshukla04/react-native-nitro-player/llms.txt Use `PlayerQueue.createPlaylist` to create named playlists and `PlayerQueue.addTracksToPlaylist` to add tracks. Load playlists into the player using `PlayerQueue.loadPlaylist` and start playback with `TrackPlayer.play`. ```typescript import { PlayerQueue, TrackPlayer } from 'react-native-nitro-player'; import type { TrackItem } from 'react-native-nitro-player'; const tracks: TrackItem[] = [ { id: '1', title: 'Midnight Drive', artist: 'Synthwave FM', album: 'Neon Highways', duration: 245, url: 'https://cdn.example.com/midnight-drive.mp3', artwork: 'https://cdn.example.com/art/neon.jpg', extraPayload: { genre: 'Synthwave', isFavorite: true }, }, { id: '2', title: 'Ocean Breeze', artist: 'Lo-Fi Beats', album: 'Chill Sessions', duration: 198, url: 'https://cdn.example.com/ocean-breeze.mp3', }, ]; const playlistId = await PlayerQueue.createPlaylist( 'Road Trip', 'Summer driving playlist', 'https://cdn.example.com/art/road-trip.jpg' ); // Insert at the beginning await PlayerQueue.addTracksToPlaylist(playlistId, tracks, 0); // Load into player and start await PlayerQueue.loadPlaylist(playlistId); await TrackPlayer.play(); // Read playlists synchronously const playlist = PlayerQueue.getPlaylist(playlistId); // Playlist | null const all = PlayerQueue.getAllPlaylists(); // Playlist[] const current = PlayerQueue.getCurrentPlaylistId(); // string | null ``` -------------------------------- ### Get Storage Info Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieves information about the download storage usage. ```APIDOC ## getStorageInfo() ### Description Get download storage usage information. ### Method ```typescript DownloadManager.getStorageInfo() ``` ### Response #### Success Response - **Promise** - A promise that resolves with an object containing storage details like total downloaded size, track count, playlist count, and available/total space. ### Request Example ```typescript const info = await DownloadManager.getStorageInfo(); // { totalDownloadedSize, trackCount, playlistCount, availableSpace, totalSpace } ``` ``` -------------------------------- ### Load Playlist for Playback Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/player-queue.mdx Load a playlist into the player. Playback can be started subsequently by calling `TrackPlayer.play()`. ```typescript await PlayerQueue.loadPlaylist('playlist-123'); await TrackPlayer.play(); ``` -------------------------------- ### Get Up Next Queue Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Retrieves the current 'upNext' queue. The track at index 0 will play first. ```typescript const upNext = await TrackPlayer.getUpNextQueue(); ``` -------------------------------- ### Create Playlist and Play Music Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/quick-start.mdx Create a playlist, add defined tracks to it, load the playlist, and begin playback. This sequence initializes the player with your music. ```typescript import { TrackPlayer, PlayerQueue } from 'react-native-nitro-player'; // Create a playlist const playlistId = await PlayerQueue.createPlaylist( 'My Playlist', 'My first playlist' ); // Add tracks await PlayerQueue.addTracksToPlaylist(playlistId, tracks); // Load and play await PlayerQueue.loadPlaylist(playlistId); await TrackPlayer.play(); ``` -------------------------------- ### ExoPlayer Initialization with Looper Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/progress-update.md Demonstrates initializing ExoPlayer with a specific looper from a HandlerThread. This ensures the player is owned by the dedicated player thread. ```kotlin val player = ExoPlayer.Builder(context) .setLooper(playerThread.looper) .build() ``` -------------------------------- ### AndroidManifest.xml Setup for MediaBrowserService Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/guides/android-auto.mdx Declare the `NitroPlayerMediaBrowserService` in your `AndroidManifest.xml` to expose your app's media browse tree to Android Auto. Ensure the `tools` namespace is declared in the manifest tag. ```xml ``` ```xml ``` -------------------------------- ### Configure and Use Download Manager Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Initialize the `DownloadManager` with `configure` to set download limits and preferences. Use `downloadTrack` or `downloadPlaylist` for offline playback. `setPlaybackSourcePreference` can be used to prioritize downloaded tracks. ```typescript import { DownloadManager } from 'react-native-nitro-player' // Configure downloads DownloadManager.configure({ maxConcurrentDownloads: 3, backgroundDownloadsEnabled: true, downloadArtwork: true, }) // Download a track const downloadId = await DownloadManager.downloadTrack(track) // Download entire playlist const playlist = PlayerQueue.getPlaylist(playlistId) await DownloadManager.downloadPlaylist(playlist.id, playlist.tracks) // Set playback to prefer downloaded tracks DownloadManager.setPlaybackSourcePreference('auto') ``` -------------------------------- ### Get Local Path Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Gets the local file path for a downloaded track. ```APIDOC ## getLocalPath(trackId) ### Description Get the local file path for a downloaded track. ### Method ```typescript DownloadManager.getLocalPath(trackId: string) ``` ### Parameters #### Path Parameters - **trackId** (string) - Required - The ID of the track. ### Response #### Success Response - **Promise** - A promise that resolves with the local file path or null if the track is not downloaded. ### Request Example ```typescript const path = await DownloadManager.getLocalPath('track-1'); ``` ``` -------------------------------- ### Create Playlists Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Demonstrates how to create a new playlist and add tracks to it using the PlayerQueue module. ```APIDOC ## Create Playlists ### Description Creates a new playlist with a given title, description, and artwork, then adds a list of tracks to it. ### Method `PlayerQueue.createPlaylist(title: string, description: string, artworkUrl: string): Promise` `PlayerQueue.addTracksToPlaylist(playlistId: string, tracks: TrackItem[]): Promise` ### Parameters #### `createPlaylist` - **title** (string) - Required - The name of the playlist. - **description** (string) - Required - A brief description of the playlist. - **artworkUrl** (string) - Required - The URL for the playlist's artwork. #### `addTracksToPlaylist` - **playlistId** (string) - Required - The ID of the playlist to add tracks to. - **tracks** (TrackItem[]) - Required - An array of track objects to add to the playlist. ### Request Example ```typescript import { PlayerQueue } from 'react-native-nitro-player' import type { TrackItem } from 'react-native-nitro-player' const tracks: TrackItem[] = [ { id: '1', title: 'Song Title', artist: 'Artist Name', album: 'Album Name', duration: 180.0, // in seconds url: 'https://example.com/song.mp3', artwork: 'https://example.com/artwork.jpg', extraPayload: { artistId: '123', genre: 'Rock', isFavorite: true, }, }, ] const playlistId = await PlayerQueue.createPlaylist( 'My Playlist', 'Playlist description', 'https://example.com/playlist-artwork.jpg' ) await PlayerQueue.addTracksToPlaylist(playlistId, tracks) ``` ``` -------------------------------- ### Set Up Local Include Directories Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/android/CMakeLists.txt Configures the directories from which C++ source files can include headers. ```cmake include_directories( "src/main/cpp" "../cpp" ) ``` -------------------------------- ### Configure Download Manager Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/DOWNLOADS.md Set up the download manager with options like concurrent downloads, retries, and storage location. ```typescript import { DownloadManager } from 'react-native-nitro-player' DownloadManager.configure({ maxConcurrentDownloads: 3, autoRetry: true, maxRetryAttempts: 3, backgroundDownloadsEnabled: true, downloadArtwork: true, wifiOnlyDownloads: false, storageLocation: 'private', // 'private' or 'public' }) ``` -------------------------------- ### Get Playback State and Reason with useOnPlaybackStateChange Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/README.md Use `useOnPlaybackStateChange` to get the current playback state (playing, paused, or stopped) and the reason for any state changes. ```typescript const { state, reason } = useOnPlaybackStateChange() ``` -------------------------------- ### Get Download State for a Track Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/DOWNLOADS.md Get the current download state for a given track ID. Possible states include 'pending', 'downloading', 'paused', 'completed', 'failed', and 'cancelled'. ```typescript getDownloadState(trackId: string): DownloadState | null ``` -------------------------------- ### Get Download Queue Status Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/DOWNLOADS.md Get an overview of the download queue, including counts of pending, active, completed, and failed downloads, as well as total bytes and overall progress. ```typescript { pendingCount: number activeCount: number completedCount: number failedCount: number totalBytesToDownload: number totalBytesDownloaded: number overallProgress: number // 0.0 to 1.0 } ``` -------------------------------- ### Player Configuration Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/README.md Initial configuration for the player, including platform-specific options. ```APIDOC ## Player Configuration ### `TrackPlayer.configure(options)` - **Description**: Configures the player with various settings before it can be used. - **Example**: ```typescript import { TrackPlayer } from 'react-native-nitro-player' await TrackPlayer.configure({ androidAutoEnabled: true, carPlayEnabled: false, showInNotification: true, }) ``` ``` -------------------------------- ### Get Resolved Queue with `useActualQueue` Hook Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/guides/queue-management.mdx Use the `useActualQueue` hook to reactively get the fully resolved playback queue, including temporary tracks and the playlist. This hook provides the queue and a loading state. ```tsx import { useActualQueue } from 'react-native-nitro-player'; function QueueScreen() { const { queue, isLoading } = useActualQueue(); // queue = resolved order including temporary tracks } ``` -------------------------------- ### State & Configuration Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Methods for retrieving player state and configuring player settings. ```APIDOC ## getState() ### Description Get the current player state. ### Method `getState()` ### Returns `Promise` - See [PlayerState](/docs/types#playerstate) ``` ```APIDOC ## setRepeatMode(mode) ### Description Set the repeat mode. ### Method `setRepeatMode(mode: RepeatMode)` ### Parameters #### Path Parameters - **mode** (RepeatMode) - Required - 'off' | 'Playlist' | 'track' ### Returns `Promise` ``` ```APIDOC ## getRepeatMode() ### Description Get the current repeat mode. **Synchronous.** ### Method `getRepeatMode()` ### Returns `RepeatMode` ``` ```APIDOC ## configure(config) ### Description Configure the player. Call this early in your app lifecycle. ### Method `configure(config: PlayerConfig)` ### Parameters #### Path Parameters - **config** (PlayerConfig) - Required - See [PlayerConfig](/docs/types#playerconfig) ### Returns `Promise` ``` -------------------------------- ### Get All Downloaded Playlists Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieves all currently downloaded playlists. ```APIDOC ## getAllDownloadedPlaylists() ### Description Retrieves all currently downloaded playlists. ### Method ```typescript DownloadManager.getAllDownloadedPlaylists() ``` ### Response #### Success Response - **Promise** - A promise that resolves with an array of all downloaded playlist objects. ### Request Example ```typescript const playlists = await DownloadManager.getAllDownloadedPlaylists(); ``` ``` -------------------------------- ### Get All Downloaded Tracks Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieves all currently downloaded tracks. ```APIDOC ## getAllDownloadedTracks() ### Description Retrieves all currently downloaded tracks. ### Method ```typescript DownloadManager.getAllDownloadedTracks() ``` ### Response #### Success Response - **Promise** - A promise that resolves with an array of all downloaded track objects. ### Request Example ```typescript const tracks = await DownloadManager.getAllDownloadedTracks(); ``` ``` -------------------------------- ### Create and Add Tracks to a Playlist Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Use `PlayerQueue.createPlaylist` to initialize a new playlist and `PlayerQueue.addTracksToPlaylist` to populate it. Ensure `TrackItem` objects include necessary metadata like id, title, artist, duration, and URL. ```typescript import { PlayerQueue } from 'react-native-nitro-player' import type { TrackItem } from 'react-native-nitro-player' const tracks: TrackItem[] = [ { id: '1', title: 'Song Title', artist: 'Artist Name', album: 'Album Name', duration: 180.0, // in seconds url: 'https://example.com/song.mp3', artwork: 'https://example.com/artwork.jpg', // Optional custom data (accessible in player state) extraPayload: { artistId: '123', genre: 'Rock', isFavorite: true, }, }, ] const playlistId = await PlayerQueue.createPlaylist( 'My Playlist', 'Playlist description', 'https://example.com/playlist-artwork.jpg' ) await PlayerQueue.addTracksToPlaylist(playlistId, tracks) ``` -------------------------------- ### Get Downloaded Playlist Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieves a specific downloaded playlist by its ID. ```APIDOC ## getDownloadedPlaylist(playlistId) ### Description Retrieves a specific downloaded playlist by its ID. ### Method ```typescript DownloadManager.getDownloadedPlaylist(playlistId: string) ``` ### Parameters #### Path Parameters - **playlistId** (string) - Required - The ID of the playlist to retrieve. ### Response #### Success Response - **Promise** - A promise that resolves with the downloaded playlist object or null if not found. ### Request Example ```typescript const playlist = await DownloadManager.getDownloadedPlaylist('playlist-123'); ``` ``` -------------------------------- ### createPlaylist Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/player-queue.mdx Creates a new playlist with an optional name, description, and artwork. ```APIDOC ## createPlaylist(name, description?, artwork?) ### Description Create a new playlist. ### Parameters #### Path Parameters - **name** (string) - Required - Playlist name - **description** (string) - Optional - Playlist description - **artwork** (string) - Optional - Artwork URL ### Request Example ```typescript const playlistId = await PlayerQueue.createPlaylist( 'Road Trip', 'Summer driving playlist', 'https://example.com/art/road-trip.jpg' ); ``` ### Response #### Success Response (200) - **playlistId** (string) - The new playlist ID ``` -------------------------------- ### Get Downloaded Track Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieves a specific downloaded track by its ID. ```APIDOC ## getDownloadedTrack(trackId) ### Description Retrieves a specific downloaded track by its ID. ### Method ```typescript DownloadManager.getDownloadedTrack(trackId: string) ``` ### Parameters #### Path Parameters - **trackId** (string) - Required - The ID of the track to retrieve. ### Response #### Success Response - **Promise** - A promise that resolves with the downloaded track object or null if not found. ### Request Example ```typescript const track = await DownloadManager.getDownloadedTrack('track-1'); ``` ``` -------------------------------- ### Project and Build Configuration Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/android/CMakeLists.txt Sets the project name, minimum CMake version, and build verbosity. Configures the C++ standard to be used. ```cmake project(NitroPlayer) cmake_minimum_required(VERSION 3.9.0) set (PACKAGE_NAME NitroPlayer) set (CMAKE_VERBOSE_MAKEFILE ON) set (CMAKE_CXX_STANDARD 20) ``` -------------------------------- ### Configure Player Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Initialize and configure the player with specific settings. This method should be called early in the application's lifecycle. ```typescript await TrackPlayer.configure({ androidAutoEnabled: true, showInNotification: true, lookaheadCount: 10, }); ``` -------------------------------- ### Get All Playlists Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/player-queue.mdx Retrieve all playlists currently managed by the player. This operation is synchronous. ```typescript const playlists = PlayerQueue.getAllPlaylists(); ``` -------------------------------- ### Enable Equalizer Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/equalizer.mdx Use this method to turn the equalizer on. Ensure the Equalizer is imported before use. ```typescript import { Equalizer } from 'react-native-nitro-player'; await Equalizer.setEnabled(true); ``` -------------------------------- ### Get Player State Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/README.md Obtains a snapshot of the current player state. This is an asynchronous operation. ```javascript const state = await TrackPlayer.getState(); ``` -------------------------------- ### Configure Download Manager Settings Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/guides/offline-playback.mdx Set up download parameters such as concurrent downloads, retry attempts, and storage location using the DownloadManager.configure method. ```typescript import { DownloadManager } from 'react-native-nitro-player'; DownloadManager.configure({ maxConcurrentDownloads: 3, autoRetry: true, maxRetryAttempts: 3, backgroundDownloadsEnabled: true, downloadArtwork: true, wifiOnlyDownloads: false, storageLocation: 'private', }); ``` -------------------------------- ### Get Repeat Mode Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/react-native-nitro-player/README.md Retrieves the current repeat mode of the player. This is a synchronous operation. ```javascript const repeatMode = TrackPlayer.getRepeatMode(); ``` -------------------------------- ### Get Repeat Mode Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Retrieve the current repeat mode setting. This operation is synchronous. ```typescript const mode = TrackPlayer.getRepeatMode(); // 'off' | 'Playlist' | 'track' ``` -------------------------------- ### On Download Complete Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Registers a callback to be notified when a download finishes successfully. ```APIDOC ## onDownloadComplete(callback) ### Description Called when a download finishes successfully. ### Method ```typescript DownloadManager.onDownloadComplete(callback: (downloadedTrack: DownloadedTrack) => void) ``` ### Parameters #### Path Parameters - **callback** (function) - Required - A function that will be called with the details of the completed download. - **downloadedTrack** (DownloadedTrack) - The object representing the successfully downloaded track. ### Request Example ```typescript DownloadManager.onDownloadComplete((downloadedTrack) => { console.log(`Downloaded: ${downloadedTrack.originalTrack.title}`); console.log(`Local path: ${downloadedTrack.localPath}`); }); ``` ``` -------------------------------- ### Create Playlist Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/player-queue.mdx Create a new playlist with a name, optional description, and artwork URL. Returns the ID of the newly created playlist. ```typescript const playlistId = await PlayerQueue.createPlaylist( 'Road Trip', 'Summer driving playlist', 'https://example.com/art/road-trip.jpg' ); ``` -------------------------------- ### Get Playback Speed Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Retrieve the current playback speed multiplier. This is an asynchronous operation. ```typescript const speed = await TrackPlayer.getPlaybackSpeed(); ``` -------------------------------- ### DownloadConfig Interface Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/types/index.mdx Configuration options for managing audio downloads, including storage location and retry settings. Allows customization of download behavior. ```typescript interface DownloadConfig { storageLocation?: StorageLocation; // 'private' | 'public' maxConcurrentDownloads?: number; autoRetry?: boolean; maxRetryAttempts?: number; backgroundDownloadsEnabled?: boolean; downloadArtwork?: boolean; customDownloadPath?: string | null; wifiOnlyDownloads?: boolean; } ``` -------------------------------- ### Get Tracks By IDs Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/track-player.mdx Retrieves track items from all playlists based on provided track IDs. ```APIDOC ## getTracksById(trackIds) ### Description Get tracks by IDs from all playlists. ### Parameters #### Path Parameters - **trackIds** (string[]) - Required - Array of track IDs ### Request Example ```typescript const tracks = await TrackPlayer.getTracksById(['id-1', 'id-2']); ``` ### Response #### Success Response (200) - **tracks** (TrackItem[]) - Array of track items matching the provided IDs. ``` -------------------------------- ### Equalizer - Enable, Band Control, and Presets Source: https://context7.com/riteshshukla04/react-native-nitro-player/llms.txt Control the 10-band equalizer, including enabling/disabling, setting individual band gains, applying presets, and managing custom presets. Use `getState` for a full snapshot. ```typescript import { Equalizer } from 'react-native-nitro-player'; // Enable / disable await Equalizer.setEnabled(true); const enabled = Equalizer.isEnabled(); // synchronous // Read all bands const bands = await Equalizer.getBands(); // [{ index: 0, centerFrequency: 31, gainDb: 0, frequencyLabel: '31 Hz' }, ...] const range = Equalizer.getBandRange(); // synchronous → { min: -12, max: 12 } // Boost bass (band 0) by 6 dB, cut treble (band 9) await Equalizer.setBandGain(0, 6.0); await Equalizer.setBandGain(9, -3.0); // Set all 10 bands at once (V-shape EQ) await Equalizer.setAllBandGains([6, 4, 2, 0, -2, -2, 0, 2, 4, 6]); // Apply a built-in preset const presets = Equalizer.getBuiltInPresets(); // synchronous await Equalizer.applyPreset('Rock'); const currentPreset = Equalizer.getCurrentPresetName(); // 'Rock' // Save / delete custom preset await Equalizer.saveCustomPreset('My Bass Boost'); const custom = Equalizer.getCustomPresets(); // synchronous await Equalizer.deleteCustomPreset('My Bass Boost'); // Get full state snapshot const state = await Equalizer.getState(); // { enabled: true, bands: [...], currentPreset: 'Rock' } // Reset to flat await Equalizer.reset(); ``` -------------------------------- ### TrackPlayer Methods Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/README.md Command-style methods for controlling the audio player. Most methods return a Promise and reject on failure. ```APIDOC ## TrackPlayer Methods ### `play()` - **Description**: Resumes playback. - **Platform**: Both - **Returns**: `Promise` ### `pause()` - **Description**: Pauses playback. - **Platform**: Both - **Returns**: `Promise` ### `playSong(id, playlistId?)` - **Description**: Plays a specific song, optionally from a playlist. - **Parameters**: - **id** (string) - Required - The ID of the song to play. - **playlistId** (string) - Optional - The ID of the playlist the song belongs to. - **Platform**: Both - **Returns**: `Promise` ### `skipToNext()` - **Description**: Skips to the next track in the queue. - **Platform**: Both - **Returns**: `Promise` ### `skipToPrevious()` - **Description**: Skips to the previous track. - **Platform**: Both - **Returns**: `Promise` ### `seek(position)` - **Description**: Seeks to a specific time position in seconds. - **Parameters**: - **position** (number) - Required - The time position in seconds. - **Platform**: Both - **Returns**: `Promise` ### `setPlaybackSpeed(speed)` - **Description**: Sets playback speed (e.g. 0.5x, 1x, 1.5x, 2x). - **Parameters**: - **speed** (number) - Required - The desired playback speed. - **Platform**: Both - **Returns**: `Promise` ### `getPlaybackSpeed()` - **Description**: Gets the current playback speed. - **Platform**: Both - **Returns**: `Promise` ### `setVolume(0-100)` - **Description**: Sets playback volume (0-100). - **Parameters**: - **volume** (number) - Required - The desired volume level (0-100). - **Platform**: Both - **Returns**: `Promise` ### `setRepeatMode(mode)` - **Description**: Sets repeat mode (`off`, `track`, `Playlist`). - **Parameters**: - **mode** (string) - Required - The repeat mode ('off', 'track', 'Playlist'). - **Platform**: Both - **Returns**: `Promise` ### `getRepeatMode()` - **Description**: Gets the current repeat mode. - **Platform**: Both - **Returns**: `string` (Synchronous read) ### `addToUpNext(id)` - **Description**: Adds a track to the "up next" queue (FIFO). - **Parameters**: - **id** (string) - Required - The ID of the track to add. - **Platform**: Both - **Returns**: `Promise` ### `playNext(id)` - **Description**: Adds a track to the "play next" stack (LIFO). - **Parameters**: - **id** (string) - Required - The ID of the track to add. - **Platform**: Both - **Returns**: `Promise` ### `getActualQueue()` - **Description**: Gets the full playback queue including temporary tracks. - **Platform**: Both - **Returns**: `Promise>` ### `getState()` - **Description**: Gets a snapshot of the player state. - **Platform**: Both - **Returns**: `Promise` ### `skipToIndex(index)` - **Description**: Skips to an index in the actual queue. - **Parameters**: - **index** (number) - Required - The index to skip to. - **Platform**: Both - **Returns**: `Promise` ### `configure(config)` - **Description**: Configures player settings (Android Auto, CarPlay, notification). - **Parameters**: - **config** (object) - Required - Configuration object. - **Platform**: Both - **Returns**: `Promise` ### `isAndroidAutoConnected()` - **Description**: Checks if Android Auto is connected. - **Platform**: Both - **Returns**: `boolean` (Synchronous read) ``` -------------------------------- ### Get Specific Download Task Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieve a specific download task by its ID. This is a synchronous operation. ```typescript const task = DownloadManager.getDownloadTask('dl-123'); ``` -------------------------------- ### Get Playback Source Preference Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieve the current playback source preference. This is a synchronous operation. ```typescript const pref = DownloadManager.getPlaybackSourcePreference(); ``` -------------------------------- ### DownloadManager - Configuration and Track/Playlist Downloads Source: https://context7.com/riteshshukla04/react-native-nitro-player/llms.txt Configure download settings like concurrency, retries, and storage, then initiate downloads for individual tracks or entire playlists. Use download IDs for managing individual downloads. ```typescript import { DownloadManager } from 'react-native-nitro-player'; DownloadManager.configure({ maxConcurrentDownloads: 3, autoRetry: true, maxRetryAttempts: 3, backgroundDownloadsEnabled: true, downloadArtwork: true, wifiOnlyDownloads: false, storageLocation: 'private', // 'private' | 'public' }); // Download a single track const downloadId = await DownloadManager.downloadTrack(track, 'playlist-123'); // Download a full playlist const downloadIds = await DownloadManager.downloadPlaylist('playlist-123', tracks); // Pause / resume / cancel / retry by downloadId await DownloadManager.pauseDownload(downloadId); await DownloadManager.resumeDownload(downloadId); await DownloadManager.cancelDownload(downloadId); await DownloadManager.retryDownload(downloadId); // Bulk control await DownloadManager.pauseAllDownloads(); await DownloadManager.resumeAllDownloads(); await DownloadManager.cancelAllDownloads(); ``` -------------------------------- ### Get Download Manager Configuration Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieve the current download manager configuration. This is a synchronous operation. ```typescript const config = DownloadManager.getConfig(); ``` -------------------------------- ### Configure Download Manager Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/DOWNLOADS.md Configure the download manager with various options such as storage location, concurrent downloads, and retry settings. This should be called once at the application's startup. ```typescript configure({ storageLocation: 'private', maxConcurrentDownloads: 5, autoRetry: false, customDownloadPath: '/path/to/downloads' }) ``` -------------------------------- ### loadPlaylist Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/player-queue.mdx Loads a specified playlist into the player. Playback must be started separately using `TrackPlayer.play()`. ```APIDOC ## loadPlaylist(playlistId) ### Description Load a playlist into the player. Call `TrackPlayer.play()` after to start playback. ### Parameters #### Path Parameters - **playlistId** (string) - Required - The ID of the playlist to load ### Request Example ```typescript await PlayerQueue.loadPlaylist('playlist-123'); await TrackPlayer.play(); ``` ### Response #### Success Response (200) - **void** ``` -------------------------------- ### Get All Downloaded Tracks Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/DOWNLOADS.md Asynchronously retrieve an array containing information for all tracks that have been successfully downloaded to disk. ```typescript getAllDownloadedTracks(): Promise ``` -------------------------------- ### Monitor Download Progress Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/guides/offline-playback.mdx Set up a listener to receive real-time download progress updates. Useful for displaying progress bars or updating UI elements during downloads. ```typescript DownloadManager.onDownloadProgress((progress) => { console.log(`${progress.trackId}: ${(progress.progress * 100).toFixed(1)}%`); }); ``` -------------------------------- ### Configure Download Manager Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Configure the download manager with various settings. This is a synchronous operation. ```typescript DownloadManager.configure({ maxConcurrentDownloads: 3, autoRetry: true, maxRetryAttempts: 3, backgroundDownloadsEnabled: true, downloadArtwork: true, wifiOnlyDownloads: false, storageLocation: 'private', }); ``` -------------------------------- ### Get Active Downloads Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/api/download-manager.mdx Retrieve a list of all currently active (in-progress) download tasks. This is a synchronous operation. ```typescript const active = DownloadManager.getActiveDownloads(); ``` -------------------------------- ### Track Progress with Hooks Source: https://github.com/riteshshukla04/react-native-nitro-player/blob/main/docs/content/docs/guides/offline-playback.mdx Utilize hooks to monitor download progress, manage download actions (pause, resume, cancel), and check if tracks are downloaded. ```APIDOC ## Track Progress with Hooks ```tsx import { useDownloadProgress, useDownloadActions, useDownloadedTracks, } from 'react-native-nitro-player'; function DownloadScreen() { const { progressList, overallProgress, isDownloading } = useDownloadProgress({ activeOnly: true, }); const { downloadTrack, pauseDownload, resumeDownload, cancelDownload } = useDownloadActions(); const { isTrackDownloaded } = useDownloadedTracks(); return ( Overall: {(overallProgress * 100).toFixed(0)}% {progressList.map((p) => ( {p.trackId}: {(p.progress * 100).toFixed(0)}% {p.state === 'downloading' && (