react-native-nitro-player 0.3.0-alpha.5 → 0.3.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +699 -1
  2. package/android/src/main/java/com/margelo/nitro/nitroplayer/HybridTrackPlayer.kt +4 -0
  3. package/android/src/main/java/com/margelo/nitro/nitroplayer/core/TrackPlayerCore.kt +44 -7
  4. package/ios/HybridTrackPlayer.swift +6 -0
  5. package/ios/core/TrackPlayerCore.swift +214 -41
  6. package/lib/hooks/index.d.ts +6 -0
  7. package/lib/hooks/index.js +6 -0
  8. package/lib/hooks/useAndroidAutoConnection.d.ts +13 -0
  9. package/lib/hooks/useAndroidAutoConnection.js +26 -0
  10. package/lib/hooks/useAudioDevices.d.ts +26 -0
  11. package/lib/hooks/useAudioDevices.js +55 -0
  12. package/lib/hooks/useOnChangeTrack.d.ts +9 -0
  13. package/lib/hooks/useOnChangeTrack.js +17 -0
  14. package/lib/hooks/useOnPlaybackProgressChange.d.ts +9 -0
  15. package/lib/hooks/useOnPlaybackProgressChange.js +19 -0
  16. package/lib/hooks/useOnPlaybackStateChange.d.ts +9 -0
  17. package/lib/hooks/useOnPlaybackStateChange.js +17 -0
  18. package/lib/hooks/useOnSeek.d.ts +8 -0
  19. package/lib/hooks/useOnSeek.js +17 -0
  20. package/lib/index.d.ts +15 -0
  21. package/lib/index.js +24 -0
  22. package/lib/specs/AndroidAutoMediaLibrary.nitro.d.ts +21 -0
  23. package/lib/specs/AndroidAutoMediaLibrary.nitro.js +1 -0
  24. package/lib/specs/AudioDevices.nitro.d.ts +24 -0
  25. package/lib/specs/AudioDevices.nitro.js +1 -0
  26. package/lib/specs/AudioRoutePicker.nitro.d.ts +10 -0
  27. package/lib/specs/AudioRoutePicker.nitro.js +1 -0
  28. package/lib/specs/TrackPlayer.nitro.d.ts +42 -0
  29. package/lib/specs/TrackPlayer.nitro.js +1 -0
  30. package/lib/types/AndroidAutoMediaLibrary.d.ts +44 -0
  31. package/lib/types/AndroidAutoMediaLibrary.js +1 -0
  32. package/lib/types/PlayerQueue.d.ts +32 -0
  33. package/lib/types/PlayerQueue.js +1 -0
  34. package/lib/utils/androidAutoMediaLibrary.d.ts +47 -0
  35. package/lib/utils/androidAutoMediaLibrary.js +62 -0
  36. package/nitrogen/generated/android/c++/JHybridTrackPlayerSpec.cpp +5 -0
  37. package/nitrogen/generated/android/c++/JHybridTrackPlayerSpec.hpp +1 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroplayer/HybridTrackPlayerSpec.kt +4 -0
  39. package/nitrogen/generated/ios/c++/HybridTrackPlayerSpecSwift.hpp +8 -0
  40. package/nitrogen/generated/ios/swift/HybridTrackPlayerSpec.swift +1 -0
  41. package/nitrogen/generated/ios/swift/HybridTrackPlayerSpec_cxx.swift +12 -0
  42. package/nitrogen/generated/shared/c++/HybridTrackPlayerSpec.cpp +1 -0
  43. package/nitrogen/generated/shared/c++/HybridTrackPlayerSpec.hpp +1 -0
  44. package/package.json +10 -9
  45. package/src/specs/TrackPlayer.nitro.ts +1 -0
package/README.md CHANGED
@@ -1 +1,699 @@
1
- Refer Root readme
1
+ # React Native Nitro Player
2
+
3
+ A powerful audio player library for React Native with playlist management, playback controls, and support for Android Auto and CarPlay.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install react-native-nitro-player
9
+ # or
10
+ yarn add react-native-nitro-player
11
+ ```
12
+
13
+ ### Peer Dependencies
14
+
15
+ Make sure you have these installed:
16
+
17
+ ```bash
18
+ npm install react-native-nitro-modules
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### 1. Configure the Player
24
+
25
+ Configure the player before using it in your app:
26
+
27
+ ```typescript
28
+ import { TrackPlayer } from 'react-native-nitro-player'
29
+
30
+ TrackPlayer.configure({
31
+ androidAutoEnabled: true,
32
+ carPlayEnabled: false,
33
+ showInNotification: true,
34
+ })
35
+ ```
36
+
37
+ ### 2. Create Playlists
38
+
39
+ ```typescript
40
+ import { PlayerQueue } from 'react-native-nitro-player'
41
+ import type { TrackItem } from 'react-native-nitro-player'
42
+
43
+ const tracks: TrackItem[] = [
44
+ {
45
+ id: '1',
46
+ title: 'Song Title',
47
+ artist: 'Artist Name',
48
+ album: 'Album Name',
49
+ duration: 180.0, // in seconds
50
+ url: 'https://example.com/song.mp3',
51
+ artwork: 'https://example.com/artwork.jpg',
52
+ },
53
+ ]
54
+
55
+ // Create a playlist
56
+ const playlistId = PlayerQueue.createPlaylist(
57
+ 'My Playlist',
58
+ 'Playlist description',
59
+ 'https://example.com/playlist-artwork.jpg'
60
+ )
61
+
62
+ // Add tracks to the playlist
63
+ PlayerQueue.addTracksToPlaylist(playlistId, tracks)
64
+ ```
65
+
66
+ ### 3. Play Music
67
+
68
+ ```typescript
69
+ import { TrackPlayer, PlayerQueue } from 'react-native-nitro-player'
70
+
71
+ // Load and play a playlist
72
+ PlayerQueue.loadPlaylist(playlistId)
73
+
74
+ // Or play a specific song
75
+ TrackPlayer.playSong('song-id', playlistId)
76
+
77
+ // Basic controls
78
+ TrackPlayer.play()
79
+ TrackPlayer.pause()
80
+ TrackPlayer.skipToNext()
81
+ TrackPlayer.skipToPrevious()
82
+ TrackPlayer.seek(30) // Seek to 30 seconds
83
+
84
+ // Set repeat mode
85
+ TrackPlayer.setRepeatMode('off') // No repeat
86
+ TrackPlayer.setRepeatMode('Playlist') // Repeat entire playlist
87
+ TrackPlayer.setRepeatMode('track') // Repeat current track
88
+
89
+ // Set volume (0-100)
90
+ TrackPlayer.setVolume(50) // Set volume to 50%
91
+ TrackPlayer.setVolume(0) // Mute
92
+ TrackPlayer.setVolume(100) // Maximum volume
93
+ ```
94
+
95
+ ## Core Concepts
96
+
97
+ ### PlayerQueue
98
+
99
+ Manages playlists and tracks. Use it to:
100
+
101
+ - Create, update, and delete playlists
102
+ - Add or remove tracks from playlists
103
+ - Load playlists for playback
104
+ - Listen to playlist changes
105
+
106
+ ### TrackPlayer
107
+
108
+ Controls playback. Use it to:
109
+
110
+ - Play, pause, and seek
111
+ - Skip tracks
112
+ - Control repeat mode
113
+ - Control volume
114
+ - Get current player state
115
+ - Listen to playback events
116
+
117
+ ## React Hooks
118
+
119
+ The library provides React hooks for reactive state management. These hooks automatically update your components when player state changes.
120
+
121
+ ### `useOnChangeTrack()`
122
+
123
+ Returns the current track and the reason why it changed.
124
+
125
+ **Returns:**
126
+
127
+ - `track: TrackItem | undefined` - The current track, or `undefined` if no track is playing
128
+ - `reason: Reason | undefined` - The reason for the track change (`'user_action'`, `'skip'`, `'end'`, or `'error'`)
129
+
130
+ ### `useOnPlaybackStateChange()`
131
+
132
+ Returns the current playback state and the reason for the state change.
133
+
134
+ **Returns:**
135
+
136
+ - `state: TrackPlayerState | undefined` - Current playback state (`'playing'`, `'paused'`, or `'stopped'`)
137
+ - `reason: Reason | undefined` - The reason for the state change
138
+
139
+ ### `useOnPlaybackProgressChange()`
140
+
141
+ Returns real-time playback progress updates.
142
+
143
+ **Returns:**
144
+
145
+ - `position: number` - Current playback position in seconds
146
+ - `totalDuration: number` - Total duration of the current track in seconds
147
+ - `isManuallySeeked: boolean | undefined` - `true` if the user manually seeked, `undefined` otherwise
148
+
149
+ ### `useOnSeek()`
150
+
151
+ Returns information about the last seek event.
152
+
153
+ **Returns:**
154
+
155
+ - `position: number | undefined` - The position where the user seeked to, or `undefined` if no seek has occurred
156
+ - `totalDuration: number | undefined` - The total duration at the time of seek, or `undefined` if no seek has occurred
157
+
158
+ ### `useAndroidAutoConnection()`
159
+
160
+ Monitors Android Auto connection status.
161
+
162
+ **Returns:**
163
+
164
+ - `isConnected: boolean` - `true` if connected to Android Auto, `false` otherwise
165
+
166
+ ### `useAudioDevices()` (Android only)
167
+
168
+ Automatically polls for audio device changes every 2 seconds.
169
+
170
+ **Returns:**
171
+
172
+ - `devices: TAudioDevice[]` - Array of available audio devices
173
+
174
+ ## Audio Device APIs
175
+
176
+ ### `AudioDevices` (Android only)
177
+
178
+ Android-specific API for managing audio output devices.
179
+
180
+ #### `getAudioDevices(): TAudioDevice[]`
181
+
182
+ Returns the list of available audio output devices.
183
+
184
+ **Returns:** Array of `TAudioDevice` objects with:
185
+
186
+ - `id: number` - Unique device ID
187
+ - `name: string` - Device name (e.g., "Built-in Speaker", "Bluetooth")
188
+ - `type: number` - Device type constant
189
+ - `isActive: boolean` - Whether this device is currently active
190
+
191
+ **Example:**
192
+
193
+ ```typescript
194
+ import { AudioDevices } from 'react-native-nitro-player'
195
+
196
+ if (AudioDevices) {
197
+ const devices = AudioDevices.getAudioDevices()
198
+ devices.forEach(device => {
199
+ console.log(`${device.name} - Active: ${device.isActive}`)
200
+ })
201
+ }
202
+ ```
203
+
204
+ #### `setAudioDevice(deviceId: number): boolean`
205
+
206
+ Sets the active audio output device.
207
+
208
+ **Parameters:**
209
+
210
+ - `deviceId: number` - The ID of the device to activate
211
+
212
+ **Returns:** `true` if successful, `false` otherwise
213
+
214
+ **Example:**
215
+
216
+ ```typescript
217
+ import { AudioDevices } from 'react-native-nitro-player'
218
+
219
+ if (AudioDevices) {
220
+ const success = AudioDevices.setAudioDevice(deviceId)
221
+ console.log(`Device switch: ${success ? 'success' : 'failed'}`)
222
+ }
223
+ ```
224
+
225
+ ### `AudioRoutePicker` (iOS only)
226
+
227
+ iOS-specific API for displaying the native audio route picker (AirPlay menu).
228
+
229
+ #### `showRoutePicker(): void`
230
+
231
+ Shows the native AVRoutePickerView for selecting audio output routes like AirPlay, Bluetooth, etc.
232
+
233
+ **Example:**
234
+
235
+ ```typescript
236
+ import { AudioRoutePicker } from 'react-native-nitro-player'
237
+
238
+ if (AudioRoutePicker) {
239
+ AudioRoutePicker.showRoutePicker()
240
+ }
241
+ ```
242
+
243
+ ## Repeat Mode
244
+
245
+ Control how tracks repeat during playback.
246
+
247
+ ### `setRepeatMode(mode: RepeatMode): boolean`
248
+
249
+ Sets the repeat mode for the player.
250
+
251
+ **Parameters:**
252
+
253
+ - `mode: 'off' | 'Playlist' | 'track'` - The repeat mode to set
254
+ - `'off'` - No repeat, playlist stops at the end
255
+ - `'Playlist'` - Repeat the entire playlist
256
+ - `'track'` - Repeat the current track only
257
+
258
+ **Returns:** `true` if successful, `false` otherwise
259
+
260
+ **Example:**
261
+
262
+ ```typescript
263
+ import { TrackPlayer } from 'react-native-nitro-player'
264
+
265
+ // Turn off repeat
266
+ TrackPlayer.setRepeatMode('off')
267
+
268
+ // Repeat entire playlist
269
+ TrackPlayer.setRepeatMode('Playlist')
270
+
271
+ // Repeat current track
272
+ TrackPlayer.setRepeatMode('track')
273
+ ```
274
+
275
+ ## Volume Control
276
+
277
+ Control the playback volume level.
278
+
279
+ ### `setVolume(volume: number): boolean`
280
+
281
+ Sets the playback volume level.
282
+
283
+ **Parameters:**
284
+
285
+ - `volume: number` - Volume level between 0 and 100
286
+ - `0` - Mute (no sound)
287
+ - `50` - Half volume
288
+ - `100` - Maximum volume
289
+
290
+ **Returns:** `true` if successful, `false` otherwise (e.g., if player is not initialized)
291
+
292
+ **Example:**
293
+
294
+ ```typescript
295
+ import { TrackPlayer } from 'react-native-nitro-player'
296
+
297
+ // Set volume to 50%
298
+ const success = TrackPlayer.setVolume(50)
299
+ if (success) {
300
+ console.log('Volume set successfully')
301
+ } else {
302
+ console.warn('Failed to set volume')
303
+ }
304
+
305
+ // Mute the player
306
+ TrackPlayer.setVolume(0)
307
+
308
+ // Set to maximum volume
309
+ TrackPlayer.setVolume(100)
310
+
311
+ // Incremental volume control
312
+ const currentVolume = 50
313
+ TrackPlayer.setVolume(currentVolume + 10) // Increase by 10%
314
+ TrackPlayer.setVolume(currentVolume - 10) // Decrease by 10%
315
+ ```
316
+
317
+ **Note:** The volume value is automatically clamped to the 0-100 range. Values outside this range will be clamped to the nearest valid value.
318
+
319
+ ## Usage Examples
320
+
321
+ ### Using React Hooks
322
+
323
+ The library provides convenient React hooks for reactive state management:
324
+
325
+ ```typescript
326
+ import {
327
+ useOnChangeTrack,
328
+ useOnPlaybackStateChange,
329
+ useOnPlaybackProgressChange,
330
+ useOnSeek,
331
+ useAndroidAutoConnection,
332
+ } from 'react-native-nitro-player'
333
+
334
+ function PlayerComponent() {
335
+ // Get current track
336
+ const { track, reason } = useOnChangeTrack()
337
+
338
+ // Get playback state (playing, paused, stopped)
339
+ const { state, reason: stateReason } = useOnPlaybackStateChange()
340
+
341
+ // Get playback progress
342
+ const { position, totalDuration, isManuallySeeked } = useOnPlaybackProgressChange()
343
+
344
+ // Get seek events
345
+ const { position: seekPosition, totalDuration: seekDuration } = useOnSeek()
346
+
347
+ // Check Android Auto connection
348
+ const { isConnected } = useAndroidAutoConnection()
349
+
350
+ return (
351
+ <View>
352
+ {track && (
353
+ <Text>Now Playing: {track.title} by {track.artist}</Text>
354
+ )}
355
+ <Text>State: {state}</Text>
356
+ <Text>Progress: {position} / {totalDuration}</Text>
357
+ </View>
358
+ )
359
+ }
360
+ ```
361
+
362
+ ### Managing Playlists
363
+
364
+ ```typescript
365
+ import { PlayerQueue } from 'react-native-nitro-player'
366
+ import type { TrackItem, Playlist } from 'react-native-nitro-player'
367
+
368
+ // Get all playlists
369
+ const playlists = PlayerQueue.getAllPlaylists()
370
+
371
+ // Get a specific playlist
372
+ const playlist = PlayerQueue.getPlaylist(playlistId)
373
+
374
+ // Get current playing playlist
375
+ const currentPlaylistId = PlayerQueue.getCurrentPlaylistId()
376
+
377
+ // Update playlist metadata
378
+ PlayerQueue.updatePlaylist(playlistId, {
379
+ name: 'Updated Name',
380
+ description: 'New description',
381
+ artwork: 'https://example.com/new-artwork.jpg',
382
+ })
383
+
384
+ // Add a single track
385
+ PlayerQueue.addTrackToPlaylist(playlistId, newTrack)
386
+
387
+ // Add multiple tracks
388
+ PlayerQueue.addTracksToPlaylist(playlistId, [track1, track2, track3])
389
+
390
+ // Remove a track
391
+ PlayerQueue.removeTrackFromPlaylist(playlistId, trackId)
392
+
393
+ // Reorder tracks
394
+ PlayerQueue.reorderTrackInPlaylist(playlistId, trackId, newIndex)
395
+
396
+ // Delete a playlist
397
+ PlayerQueue.deletePlaylist(playlistId)
398
+ ```
399
+
400
+ ### Listening to Events
401
+
402
+ ```typescript
403
+ import { PlayerQueue, TrackPlayer } from 'react-native-nitro-player'
404
+
405
+ // Listen to playlist changes
406
+ PlayerQueue.onPlaylistsChanged((playlists, operation) => {
407
+ console.log('Playlists updated:', operation)
408
+ // operation can be: 'add', 'remove', 'clear', 'update'
409
+ })
410
+
411
+ // Listen to specific playlist changes
412
+ PlayerQueue.onPlaylistChanged((playlistId, playlist, operation) => {
413
+ console.log('Playlist changed:', playlistId, operation)
414
+ })
415
+
416
+ // Listen to track changes
417
+ TrackPlayer.onChangeTrack((track, reason) => {
418
+ console.log('Track changed:', track.title, reason)
419
+ // reason can be: 'user_action', 'skip', 'end', 'error'
420
+ })
421
+
422
+ // Listen to playback state changes
423
+ TrackPlayer.onPlaybackStateChange((state, reason) => {
424
+ console.log('State changed:', state, reason)
425
+ })
426
+
427
+ // Listen to seek events
428
+ TrackPlayer.onSeek((position, totalDuration) => {
429
+ console.log('Seeked to:', position)
430
+ })
431
+
432
+ // Listen to playback progress
433
+ TrackPlayer.onPlaybackProgressChange(
434
+ (position, totalDuration, isManuallySeeked) => {
435
+ console.log('Progress:', position, '/', totalDuration)
436
+ }
437
+ )
438
+
439
+ // Listen to Android Auto connection changes
440
+ TrackPlayer.onAndroidAutoConnectionChange(connected => {
441
+ console.log('Android Auto:', connected ? 'Connected' : 'Disconnected')
442
+ })
443
+ ```
444
+
445
+ ### Getting Player State
446
+
447
+ ```typescript
448
+ import { TrackPlayer } from 'react-native-nitro-player'
449
+
450
+ const state = TrackPlayer.getState()
451
+
452
+ console.log(state.currentState) // 'playing' | 'paused' | 'stopped'
453
+ console.log(state.currentPosition) // current position in seconds
454
+ console.log(state.totalDuration) // total duration in seconds
455
+ console.log(state.currentTrack) // current TrackItem or null
456
+ console.log(state.currentPlaylistId) // current playlist ID or null
457
+ console.log(state.currentIndex) // current track index in playlist
458
+ ```
459
+
460
+ ## Track Item Structure
461
+
462
+ Each track must follow this structure:
463
+
464
+ ```typescript
465
+ interface TrackItem {
466
+ id: string // Unique identifier
467
+ title: string // Track title
468
+ artist: string // Artist name
469
+ album: string // Album name
470
+ duration: number // Duration in seconds
471
+ url: string // Audio file URL
472
+ artwork?: string | null // Optional artwork URL
473
+ }
474
+ ```
475
+
476
+ ## Playlist Structure
477
+
478
+ ```typescript
479
+ interface Playlist {
480
+ id: string // Unique identifier
481
+ name: string // Playlist name
482
+ description?: string | null // Optional description
483
+ artwork?: string | null // Optional artwork URL
484
+ tracks: TrackItem[] // Array of tracks
485
+ }
486
+ ```
487
+
488
+ ## Android Auto Customization
489
+
490
+ Customize how your music library appears in Android Auto with a custom folder structure.
491
+
492
+ ### Basic Setup
493
+
494
+ By default, all playlists are shown in Android Auto. You can create a custom structure:
495
+
496
+ ```typescript
497
+ import { AndroidAutoMediaLibraryHelper } from 'react-native-nitro-player'
498
+ import type { MediaLibrary } from 'react-native-nitro-player'
499
+
500
+ // Check if available (Android only)
501
+ if (AndroidAutoMediaLibraryHelper.isAvailable()) {
502
+ const mediaLibrary: MediaLibrary = {
503
+ layoutType: 'grid', // 'grid' or 'list'
504
+ rootItems: [
505
+ {
506
+ id: 'my_music',
507
+ title: '🎵 My Music',
508
+ subtitle: 'Your music collection',
509
+ mediaType: 'folder',
510
+ isPlayable: false,
511
+ layoutType: 'grid',
512
+ children: [
513
+ {
514
+ id: 'favorites',
515
+ title: 'Favorites',
516
+ subtitle: '10 tracks',
517
+ mediaType: 'playlist',
518
+ playlistId: 'my-playlist-id', // References a playlist created with PlayerQueue
519
+ isPlayable: false,
520
+ },
521
+ ],
522
+ },
523
+ {
524
+ id: 'recent',
525
+ title: '🕐 Recently Played',
526
+ mediaType: 'folder',
527
+ isPlayable: false,
528
+ children: [
529
+ // More playlist references...
530
+ ],
531
+ },
532
+ ],
533
+ }
534
+
535
+ AndroidAutoMediaLibraryHelper.set(mediaLibrary)
536
+ }
537
+
538
+ // Reset to default (show all playlists)
539
+ AndroidAutoMediaLibraryHelper.clear()
540
+ ```
541
+
542
+ ### MediaLibrary Structure
543
+
544
+ ```typescript
545
+ interface MediaLibrary {
546
+ layoutType: 'grid' | 'list' // Default layout for items
547
+ rootItems: MediaItem[] // Top-level items
548
+ appName?: string // Optional app name
549
+ appIconUrl?: string // Optional app icon
550
+ }
551
+
552
+ interface MediaItem {
553
+ id: string // Unique identifier
554
+ title: string // Display title
555
+ subtitle?: string // Optional subtitle
556
+ iconUrl?: string // Optional icon/artwork URL
557
+ isPlayable: boolean // Whether item can be played
558
+ mediaType: 'folder' | 'audio' | 'playlist' // Type of item
559
+ playlistId?: string // Reference to playlist (for playlist items)
560
+ children?: MediaItem[] // Child items (for folders)
561
+ layoutType?: 'grid' | 'list' // Override default layout
562
+ }
563
+ ```
564
+
565
+ ### Example: Organizing Playlists by Genre
566
+
567
+ ```typescript
568
+ import {
569
+ PlayerQueue,
570
+ AndroidAutoMediaLibraryHelper,
571
+ } from 'react-native-nitro-player'
572
+
573
+ // Create playlists first
574
+ const rockPlaylistId = PlayerQueue.createPlaylist('Rock Classics')
575
+ const jazzPlaylistId = PlayerQueue.createPlaylist('Jazz Essentials')
576
+ const popPlaylistId = PlayerQueue.createPlaylist('Pop Hits')
577
+
578
+ // Add tracks to playlists...
579
+ PlayerQueue.addTracksToPlaylist(rockPlaylistId, rockTracks)
580
+ PlayerQueue.addTracksToPlaylist(jazzPlaylistId, jazzTracks)
581
+ PlayerQueue.addTracksToPlaylist(popPlaylistId, popTracks)
582
+
583
+ // Create custom Android Auto structure
584
+ AndroidAutoMediaLibraryHelper.set({
585
+ layoutType: 'list',
586
+ rootItems: [
587
+ {
588
+ id: 'genres',
589
+ title: '🎸 By Genre',
590
+ mediaType: 'folder',
591
+ isPlayable: false,
592
+ layoutType: 'grid',
593
+ children: [
594
+ {
595
+ id: 'rock',
596
+ title: 'Rock',
597
+ mediaType: 'playlist',
598
+ playlistId: rockPlaylistId,
599
+ isPlayable: false,
600
+ },
601
+ {
602
+ id: 'jazz',
603
+ title: 'Jazz',
604
+ mediaType: 'playlist',
605
+ playlistId: jazzPlaylistId,
606
+ isPlayable: false,
607
+ },
608
+ {
609
+ id: 'pop',
610
+ title: 'Pop',
611
+ mediaType: 'playlist',
612
+ playlistId: popPlaylistId,
613
+ isPlayable: false,
614
+ },
615
+ ],
616
+ },
617
+ {
618
+ id: 'all_music',
619
+ title: '📀 All Music',
620
+ mediaType: 'folder',
621
+ isPlayable: false,
622
+ children: [
623
+ {
624
+ id: 'all_rock',
625
+ title: 'Rock Classics',
626
+ mediaType: 'playlist',
627
+ playlistId: rockPlaylistId,
628
+ isPlayable: false,
629
+ },
630
+ {
631
+ id: 'all_jazz',
632
+ title: 'Jazz Essentials',
633
+ mediaType: 'playlist',
634
+ playlistId: jazzPlaylistId,
635
+ isPlayable: false,
636
+ },
637
+ {
638
+ id: 'all_pop',
639
+ title: 'Pop Hits',
640
+ mediaType: 'playlist',
641
+ playlistId: popPlaylistId,
642
+ isPlayable: false,
643
+ },
644
+ ],
645
+ },
646
+ ],
647
+ })
648
+ ```
649
+
650
+ ### Notes
651
+
652
+ - The `playlistId` field must reference a playlist created with `PlayerQueue.createPlaylist()`
653
+ - Changes are immediately reflected in Android Auto
654
+ - Use folders to organize playlists hierarchically
655
+ - Grid layout is best for album/playlist browsing
656
+ - List layout is best for song lists
657
+ - Only available on Android (use `isAvailable()` to check)
658
+
659
+ ## Features
660
+
661
+ - ✅ **Playlist Management**: Create, update, and manage multiple playlists
662
+ - ✅ **Playback Controls**: Play, pause, seek, skip tracks
663
+ - ✅ **Volume Control**: Adjust playback volume (0-100)
664
+ - ✅ **React Hooks**: Built-in hooks for reactive state management
665
+ - ✅ **Event Listeners**: Listen to track changes, state changes, and more
666
+ - ✅ **Android Auto Support**: Control playback from Android Auto with customizable UI
667
+ - ✅ **CarPlay Support**: Control playback from CarPlay (iOS)
668
+ - ✅ **Notification Controls**: Show playback controls in notifications
669
+ - ✅ **Progress Tracking**: Real-time playback progress updates
670
+
671
+ ## TypeScript Support
672
+
673
+ The library is written in TypeScript and includes full type definitions. All types are exported for your convenience:
674
+
675
+ ```typescript
676
+ import type {
677
+ TrackItem,
678
+ Playlist,
679
+ PlayerState,
680
+ TrackPlayerState,
681
+ QueueOperation,
682
+ Reason,
683
+ PlayerConfig,
684
+ MediaLibrary,
685
+ MediaItem,
686
+ LayoutType,
687
+ MediaType,
688
+ } from 'react-native-nitro-player'
689
+ ```
690
+
691
+ ## Platform Support
692
+
693
+ - ✅ **iOS**: Full support with CarPlay integration
694
+ - ✅ **Android**: Full support with Android Auto integration
695
+ - 🎯 **Android Auto Media Library**: Android-only feature for customizing the Android Auto UI
696
+
697
+ ## License
698
+
699
+ MIT
@@ -94,4 +94,8 @@ class HybridTrackPlayer : HybridTrackPlayerSpec() {
94
94
 
95
95
  @Keep
96
96
  override fun isAndroidAutoConnected(): Boolean = core.isAndroidAutoConnected()
97
+
98
+ @DoNotStrip
99
+ @Keep
100
+ override fun setVolume(volume: Double): Boolean = core.setVolume(volume)
97
101
  }