react-native-mp3-player 1.0.8 → 1.0.9

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.
@@ -374,6 +374,15 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
374
374
  forwardJumpInterval = options["forwardJumpInterval"] as? NSNumber ?? forwardJumpInterval
375
375
  backwardJumpInterval = options["backwardJumpInterval"] as? NSNumber ?? backwardJumpInterval
376
376
 
377
+ // When jump intervals are set, prefer 15s rewind/forward as the main transport buttons (left/right)
378
+ // by not registering next/previous with MPRemoteCommandCenter. Only skipForward/skipBackward are used,
379
+ // so the lock screen shows "15 second rewind" on the left and "15 second forward" on the right.
380
+ let fwd = (forwardJumpInterval?.doubleValue ?? 0)
381
+ let bwd = (backwardJumpInterval?.doubleValue ?? 0)
382
+ if fwd > 0 && bwd > 0 {
383
+ capabilitiesStr = capabilitiesStr.filter { $0 != "next" && $0 != "previous" }
384
+ }
385
+
377
386
  player.remoteCommands = capabilitiesStr
378
387
  .compactMap { Capability(rawValue: $0) }
379
388
  .map { capability in
@@ -390,6 +399,11 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
390
399
  progressUpdateEventIntervalSeconds = interval
391
400
  configureProgressUpdateEvent(interval: interval)
392
401
 
402
+ // Ensure Now Playing widget is visible after options change (e.g. capabilities without next/previous).
403
+ if player.currentItem != nil && player.automaticallyUpdateNowPlayingInfo {
404
+ player.nowPlayingInfoController.pushToCenterSync()
405
+ }
406
+
393
407
  resolve(NSNull())
394
408
  }
395
409
 
@@ -7,6 +7,9 @@
7
7
 
8
8
  import Foundation
9
9
  import MediaPlayer
10
+ #if canImport(UIKit)
11
+ import UIKit
12
+ #endif
10
13
 
11
14
  public class NowPlayingInfoController: NowPlayingInfoControllerProtocol {
12
15
  private let lock = NSLock()
@@ -75,14 +78,21 @@ public class NowPlayingInfoController: NowPlayingInfoControllerProtocol {
75
78
  }
76
79
 
77
80
  /// Push the current info dictionary to MPNowPlayingInfoCenter synchronously on main so the lock screen widget appears immediately.
81
+ /// Ensures remote control events are enabled before setting info so the lock screen works on first play (not only after stop → play again).
78
82
  public func pushToCenterSync() {
79
83
  lock.lock()
80
84
  let snapshot = self.info
81
85
  lock.unlock()
82
86
  if Thread.isMainThread {
87
+ #if canImport(UIKit)
88
+ UIApplication.shared.beginReceivingRemoteControlEvents()
89
+ #endif
83
90
  infoCenter.nowPlayingInfo = snapshot
84
91
  } else {
85
92
  DispatchQueue.main.sync { [weak self] in
93
+ #if canImport(UIKit)
94
+ UIApplication.shared.beginReceivingRemoteControlEvents()
95
+ #endif
86
96
  self?.infoCenter.nowPlayingInfo = snapshot
87
97
  }
88
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mp3-player",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
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",