react-native-mp3-player 1.0.9 → 1.0.11
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.
|
@@ -332,15 +332,15 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
332
332
|
return
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
try? AVAudioSession.sharedInstance().setActive(true, options: [])
|
|
335
|
+
// Activate session whenever we have a current item so playback works after load()+play()
|
|
336
|
+
// (session may have been deactivated in setupPlayer when currentItem was nil).
|
|
337
|
+
try? audioSessionController.activateSession()
|
|
338
|
+
if #available(iOS 11.0, *) {
|
|
339
|
+
try? AVAudioSession.sharedInstance().setCategory(sessionCategory, mode: sessionCategoryMode, policy: sessionCategoryPolicy, options: sessionCategoryOptions)
|
|
340
|
+
} else {
|
|
341
|
+
try? AVAudioSession.sharedInstance().setCategory(sessionCategory, mode: sessionCategoryMode, options: sessionCategoryOptions)
|
|
343
342
|
}
|
|
343
|
+
try? AVAudioSession.sharedInstance().setActive(true, options: [])
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
@objc private func handleDidEnterBackground() {
|
|
@@ -374,13 +374,12 @@ 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,
|
|
378
|
-
//
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
capabilitiesStr = capabilitiesStr.filter { $0 != "next" && $0 != "previous" }
|
|
377
|
+
// When both jump intervals are set, use only skip-forward/skip-backward for the main transport
|
|
378
|
+
// so the lock screen shows 15s rewind (left) and 15s forward (right), not previous/next track.
|
|
379
|
+
let useJumpButtonsForTransport = (forwardJumpInterval.map { $0.intValue > 0 } ?? false)
|
|
380
|
+
&& (backwardJumpInterval.map { $0.intValue > 0 } ?? false)
|
|
381
|
+
if useJumpButtonsForTransport {
|
|
382
|
+
capabilitiesStr = capabilitiesStr.filter { $0 != "previous" && $0 != "next" }
|
|
384
383
|
}
|
|
385
384
|
|
|
386
385
|
player.remoteCommands = capabilitiesStr
|
|
@@ -399,11 +398,6 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
399
398
|
progressUpdateEventIntervalSeconds = interval
|
|
400
399
|
configureProgressUpdateEvent(interval: interval)
|
|
401
400
|
|
|
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
|
-
|
|
407
401
|
resolve(NSNull())
|
|
408
402
|
}
|
|
409
403
|
|
|
@@ -589,6 +583,8 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
589
583
|
if (rejectWhenNotInitialized(reject: reject)) { return }
|
|
590
584
|
effectivePlaybackState = .playing
|
|
591
585
|
player.play()
|
|
586
|
+
// Activate audio session when starting playback so sound actually plays (session may be inactive after setup when no track was loaded yet).
|
|
587
|
+
configureAudioSession()
|
|
592
588
|
updateNowPlayingPlaybackValuesOnMainIfNeeded()
|
|
593
589
|
resolve(NSNull())
|
|
594
590
|
emit(event: EventType.PlaybackState, body: getPlaybackStateBodyKeyValues(state: .playing))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-mp3-player",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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",
|