capacitor-plugin-playlist 0.8.0 → 0.8.1
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.
|
@@ -256,6 +256,23 @@ final class RmxAudioPlayer: NSObject {
|
|
|
256
256
|
func playCommand(_ isCommand: Bool) {
|
|
257
257
|
wasPlayingInterrupted = false
|
|
258
258
|
initializeMPCommandCenter()
|
|
259
|
+
|
|
260
|
+
// Ensure audio session is active before playing
|
|
261
|
+
// This is critical when resuming after video player has deactivated the session
|
|
262
|
+
let audioSession = AVAudioSession.sharedInstance()
|
|
263
|
+
if !audioSession.isOtherAudioPlaying {
|
|
264
|
+
// Only reactivate if no other audio is playing
|
|
265
|
+
do {
|
|
266
|
+
try audioSession.setActive(true)
|
|
267
|
+
} catch {
|
|
268
|
+
print("Warning: Could not activate audio session: \(error.localizedDescription)")
|
|
269
|
+
// Try to reactivate with category setup
|
|
270
|
+
activateAudioSession()
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
// If other audio is playing, ensure our category is set correctly
|
|
274
|
+
activateAudioSession()
|
|
275
|
+
}
|
|
259
276
|
|
|
260
277
|
if resetStreamOnPause,
|
|
261
278
|
let currentTrack = avQueuePlayer.currentAudioTrack,
|
|
@@ -1049,12 +1066,15 @@ final class RmxAudioPlayer: NSObject {
|
|
|
1049
1066
|
options.insert(.allowBluetoothA2DP)
|
|
1050
1067
|
|
|
1051
1068
|
do {
|
|
1069
|
+
// Always set category first, even if session is already active
|
|
1070
|
+
// This ensures we have the correct category after video player exits
|
|
1052
1071
|
try avSession.setCategory(.playAndRecord, options: options)
|
|
1053
1072
|
} catch {
|
|
1054
1073
|
print("Error setting category! \(error.localizedDescription)")
|
|
1055
1074
|
}
|
|
1056
1075
|
|
|
1057
1076
|
do {
|
|
1077
|
+
// Activate the session (will activate if not active, or update if already active)
|
|
1058
1078
|
try AVAudioSession.sharedInstance().setActive(true)
|
|
1059
1079
|
} catch {
|
|
1060
1080
|
print("Could not activate audio session. \(error.localizedDescription)")
|