From 4855f9beadde823fd024681321b0592e5c40a728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Fri, 13 Sep 2024 11:48:40 +0200 Subject: [PATCH] fix tvOS build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Förster --- Model/Player/PlayerModel.swift | 37 ++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index eaf02a82..356a4bc2 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -1322,26 +1322,29 @@ final class PlayerModel: ObservableObject { logger.info("Interruption type received: \(type)") // Check availability for iOS 14.5 or newer to handle interruption reason - if #available(iOS 14.5, *) { - // Extract the interruption reason, if available - if let reasonValue = info[AVAudioSessionInterruptionReasonKey] as? UInt, - let reason = AVAudioSession.InterruptionReason(rawValue: reasonValue) - { - logger.info("Interruption reason received: \(reason)") - switch reason { - case .default: - logger.info("Interruption reason: Default or unspecified interruption occurred.") - case .appWasSuspended: - logger.info("Interruption reason: The app was suspended during the interruption.") - @unknown default: - logger.info("Unknown interruption reason received.") + // Currently only for debugging purpose + #if os(iOS) + if #available(iOS 14.5, *) { + // Extract the interruption reason, if available + if let reasonValue = info[AVAudioSessionInterruptionReasonKey] as? UInt, + let reason = AVAudioSession.InterruptionReason(rawValue: reasonValue) + { + logger.info("Interruption reason received: \(reason)") + switch reason { + case .default: + logger.info("Interruption reason: Default or unspecified interruption occurred.") + case .appWasSuspended: + logger.info("Interruption reason: The app was suspended during the interruption.") + @unknown default: + logger.info("Unknown interruption reason received.") + } + } else { + logger.info("AVAudioSessionInterruptionReasonKey is missing or not a UInt in userInfo.") } } else { - logger.info("AVAudioSessionInterruptionReasonKey is missing or not a UInt in userInfo.") + logger.info("Interruption reason handling is not available on this iOS version.") } - } else { - logger.info("Interruption reason handling is not available on this iOS version.") - } + #endif // Handle the specific interruption type switch type {