File tree 1 file changed +17
-7
lines changed
1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -534,14 +534,24 @@ class AudioPlayer: NSObject {
534
534
return
535
535
}
536
536
537
- switch type {
538
- case . ended:
539
- guard let optionsValue = userInfo [ AVAudioSessionInterruptionOptionKey] as? UInt else { return }
540
- let options = AVAudioSession . InterruptionOptions ( rawValue: optionsValue)
541
- if options. contains ( . shouldResume) {
542
- self . play ( allowSeekBack: true )
537
+ // When interruption is from the app suspending then don't resume playback
538
+ if #available( iOS 14 . 5 , * ) {
539
+ let reasonValue = userInfo [ AVAudioSessionInterruptionReasonKey] as? UInt ?? 0
540
+ let reason = AVAudioSession . InterruptionReason ( rawValue: reasonValue)
541
+ if ( reason == . appWasSuspended) {
542
+ logger. log ( " AVAudioSession was suspended " )
543
+ return
543
544
}
544
- default : ( )
545
+ }
546
+
547
+ switch type {
548
+ case . ended:
549
+ guard let optionsValue = userInfo [ AVAudioSessionInterruptionOptionKey] as? UInt else { return }
550
+ let options = AVAudioSession . InterruptionOptions ( rawValue: optionsValue)
551
+ if options. contains ( . shouldResume) {
552
+ self . play ( allowSeekBack: true )
553
+ }
554
+ default : ( )
545
555
}
546
556
}
547
557
You can’t perform that action at this time.
0 commit comments