diff --git a/Model/Player/Backends/MPVClient.swift b/Model/Player/Backends/MPVClient.swift index bdb2078b..59267896 100644 --- a/Model/Player/Backends/MPVClient.swift +++ b/Model/Player/Backends/MPVClient.swift @@ -135,12 +135,6 @@ final class MPVClient: ObservableObject { checkError(mpv_initialize(mpv)) - #if !os(macOS) - // Set up audio session for Now Playing support - backend?.model.setupAudioSessionForNowPlaying() - backend?.model.updateNowPlayingInfo() - #endif - let api = UnsafeMutableRawPointer(mutating: (MPV_RENDER_API_TYPE_OPENGL as NSString).utf8String) var initParams = mpv_opengl_init_params( get_proc_address: getProcAddress, diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 3388f66d..04110392 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -1394,7 +1394,11 @@ final class PlayerModel: ObservableObject { func setAudioSessionActive(_ setActive: Bool) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { do { - try AVAudioSession.sharedInstance().setActive(setActive) + let audioSession = AVAudioSession.sharedInstance() + if setActive { + try audioSession.setCategory(.playback, mode: .moviePlayback) + } + try audioSession.setActive(setActive) } catch { self.logger.error("Error setting audio session to \(setActive): \(error)") } diff --git a/iOS/AppDelegate.swift b/iOS/AppDelegate.swift index 1ac4e497..7aac53b6 100644 --- a/iOS/AppDelegate.swift +++ b/iOS/AppDelegate.swift @@ -22,13 +22,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { OrientationTracker.shared.startDeviceOrientationTracking() OrientationModel.shared.startOrientationUpdates() - do { - try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback) - try AVAudioSession.sharedInstance().setActive(true) - } catch { - logger.error("Failed to set audio session category: \(error)") - } - UIApplication.shared.beginReceivingRemoteControlEvents() #endif