The application uses AVPlayer for streaming audio from URLs. When the device is in a low-volume, we pause the player with avplayer.pause(). We aim to implement audio interruption handling during a phone call.
Although the app successfully detects a phone call .begin state , it fails to recognize that the interruption has ended state only when only the AVPlayer is paused.
@objc func handleInterruption(notification: Notification) {
guard let userInfo = notification.userInfo else { return }
if let typeValue = userInfo[AVAudioSessionInterruptionTypeKey] as? UInt, let type = AVAudioSession.InterruptionType(rawValue: typeValue) {
switch type {
case .began:
print("begun")
case .ended:
print("ended")
}
}
}