react-native-mp3-player 1.0.1 → 1.0.3

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.
package/README.md CHANGED
@@ -9,7 +9,9 @@ React Native audio player with **reliable iOS background playback**, media contr
9
9
 
10
10
  ## Features
11
11
 
12
- - **iOS background playback** – Audio continues when the app is in the background (no ~50s cutoff). Uses `AVAudioSession` with `.longFormAudio` and interruption handling.
12
+ - **Background playback (iOS & Android)** – Audio continues when the app is in the background or the screen is locked. No patches required; compatible with current Xcode and Android 14/15.
13
+ - **iOS** – Uses `AVAudioSession` with `.longFormAudio` and interruption handling; lock screen and Control Center work natively.
14
+ - **Android** – Uses Media3 `MediaLibraryService` with `foregroundServiceType="mediaPlayback"`; system media notification, lock screen, and Android Auto are supported.
13
15
  - **Multi-platform** – Android, iOS, Windows.
14
16
  - **Media controls** – Lock screen, notification, Bluetooth, Android Auto.
15
17
  - **Queue & playback** – Add, remove, reorder tracks; play, pause, seek, repeat, crossfade (where supported).
@@ -33,6 +35,15 @@ For audio to continue when the app is backgrounded or the screen is locked (and
33
35
  2. The package configures **AVAudioSession** (category `.playback` with options for Bluetooth, AirPlay, ducking) and handles **interruptions** and **background transitions** so that playback can continue when the app is backgrounded.
34
36
  3. **Lock screen and Control Center** controls (play, pause, seek, 15-second skip) are handled **natively**, so they work even when the JavaScript thread is suspended (e.g. screen locked). When the app returns to the foreground, events are emitted so your UI stays in sync.
35
37
 
38
+ ### Android background playback
39
+
40
+ The package is built for **Android 14+** compatibility and works when the app is in the background or the screen is off:
41
+
42
+ 1. **Foreground service:** The library declares `FOREGROUND_SERVICE_MEDIA_PLAYBACK` and uses `android:foregroundServiceType="mediaPlayback"` on the playback service, as required since Android 14. No extra setup in your app is needed.
43
+ 2. **Media3 / ExoPlayer:** Playback runs in a **MediaLibraryService** (Media3), which correctly starts as a foreground service with type `mediaPlayback`, so background playback and the media notification are allowed by the system.
44
+ 3. **Media controls:** The service is advertised via **MediaSessionService** and **MediaLibraryService** so the system media notification, lock screen, Bluetooth, and Android Auto can discover and control playback.
45
+ 4. **Target SDK:** The library compiles with `compileSdkVersion` 35 and defaults to `targetSdkVersion` 34. Your app can override these via `react-native-mp3-player`’s build extras if needed. **Android 15:** Do not start the media service from a `BOOT_COMPLETED` receiver; the platform no longer allows that for media playback.
46
+
36
47
  ## Quick start
37
48
 
38
49
  ```javascript
@@ -17,6 +17,7 @@
17
17
  android:foregroundServiceType="mediaPlayback">
18
18
  <intent-filter>
19
19
  <action android:name="android.intent.action.MEDIA_BUTTON" />
20
+ <action android:name="androidx.media3.session.MediaSessionService" />
20
21
  <action android:name="androidx.media3.session.MediaLibraryService" />
21
22
  <action android:name="android.media.browse.MediaBrowserService" />
22
23
  </intent-filter>
@@ -1,6 +1,6 @@
1
1
  //
2
2
  // MetadataAdapter.swift
3
- // react-native-track-player
3
+ // react-native-mp3-player
4
4
  //
5
5
  // Created by David Chavez on 01.08.23.
6
6
  // Copyright © 2023 Double Symmetry. All rights reserved.
@@ -1,9 +1,9 @@
1
1
  #import "TrackPlayer.h"
2
2
 
3
- #if __has_include("react_native_track_player-Swift.h")
4
- #import "react_native_track_player-Swift.h"
3
+ #if __has_include("react_native_mp3_player-Swift.h")
4
+ #import "react_native_mp3_player-Swift.h"
5
5
  #else
6
- #import "react_native_track_player/react_native_track_player-Swift.h"
6
+ #import "react_native_mp3_player/react_native_mp3_player-Swift.h"
7
7
  #endif
8
8
 
9
9
  @interface NativeTrackPlayer () <RNTPDelegate>
@@ -86,12 +86,12 @@ extension AVPlayerWrapper {
86
86
 
87
87
 
88
88
  // https://stackoverflow.com/questions/79679383/unmanaged-object-pointer-build-issues-in-xcode-26-beta
89
- // XCode 26 sdk change
90
- var tapRef: MTAudioProcessingTap?
89
+ // Xcode 16+ / 26 SDK: tapOut expects Unmanaged<MTAudioProcessingTap>? (API returns retained CF object).
90
+ var tapRef: Unmanaged<MTAudioProcessingTap>?
91
91
  let error = MTAudioProcessingTapCreate(kCFAllocatorDefault, &callbacks, kMTAudioProcessingTapCreationFlag_PreEffects, &tapRef)
92
92
  assert(error == noErr)
93
93
 
94
- params.audioTapProcessor = tapRef
94
+ params.audioTapProcessor = tapRef?.takeRetainedValue()
95
95
 
96
96
  audioMix.inputParameters = [params]
97
97
  item.audioMix = audioMix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mp3-player",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "React Native audio player with reliable iOS background playback. Media controls, queue, hooks. Built for stability and long-running playback.",
5
5
  "main": "lib/src/index.js",
6
6
  "types": "lib/src/index.d.ts",