react-native-mp3-player 1.0.10 → 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))
|
|
@@ -882,9 +878,6 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
882
878
|
switch state {
|
|
883
879
|
case .ready, .playing, .paused:
|
|
884
880
|
if player.currentItem != nil && player.automaticallyUpdateNowPlayingInfo {
|
|
885
|
-
// Force push so the widget appears immediately (avoids "Not Playing" / blank artwork).
|
|
886
|
-
player.loadNowPlayingMetaValues()
|
|
887
|
-
player.nowPlayingInfoController.pushToCenterSync()
|
|
888
881
|
let useProgressTickForNowPlaying = shouldEmitProgressEvent && progressUpdateEventIntervalSeconds > 0 && progressUpdateEventIntervalSeconds <= 1.0
|
|
889
882
|
if !useProgressTickForNowPlaying {
|
|
890
883
|
scheduleNextNowPlayingUpdate()
|
|
@@ -914,12 +907,9 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
914
907
|
}
|
|
915
908
|
|
|
916
909
|
/// Updates MPNowPlayingInfoCenter (rate, elapsed, duration) synchronously so the widget reflects play/pause before we return to JS. Call after play()/pause() from JS or remote.
|
|
917
|
-
/// Also refreshes title/artist/artwork so the widget never shows "Not Playing" or blank when a track is loaded.
|
|
918
910
|
private func updateNowPlayingPlaybackValuesOnMainIfNeeded() {
|
|
919
911
|
guard player.currentItem != nil, player.automaticallyUpdateNowPlayingInfo else { return }
|
|
920
|
-
player.loadNowPlayingMetaValues()
|
|
921
912
|
player.updateNowPlayingPlaybackValuesSync()
|
|
922
|
-
player.nowPlayingInfoController.pushToCenterSync()
|
|
923
913
|
}
|
|
924
914
|
|
|
925
915
|
func handleAudioPlayerCommonMetadataReceived(metadata: [AVMetadataItem]) {
|
|
@@ -959,12 +949,10 @@ public class RNTrackPlayer: NSObject, AudioSessionControllerDelegate {
|
|
|
959
949
|
DispatchQueue.main.async {
|
|
960
950
|
UIApplication.shared.beginReceivingRemoteControlEvents();
|
|
961
951
|
}
|
|
962
|
-
// Update now playing controller with isLiveStream option from track
|
|
952
|
+
// Update now playing controller with isLiveStream option from track
|
|
963
953
|
if self.player.automaticallyUpdateNowPlayingInfo {
|
|
964
954
|
let isTrackLiveStream = (item as? Track)?.isLiveStream ?? false
|
|
965
955
|
self.player.nowPlayingInfoController.set(keyValue: NowPlayingInfoProperty.isLiveStream(isTrackLiveStream))
|
|
966
|
-
self.player.loadNowPlayingMetaValues()
|
|
967
|
-
self.player.nowPlayingInfoController.pushToCenterSync()
|
|
968
956
|
}
|
|
969
957
|
} else {
|
|
970
958
|
DispatchQueue.main.async {
|
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",
|