diff --git a/Model/Player/Backends/AVPlayerBackend.swift b/Model/Player/Backends/AVPlayerBackend.swift index c388eaad..84ac1f1c 100644 --- a/Model/Player/Backends/AVPlayerBackend.swift +++ b/Model/Player/Backends/AVPlayerBackend.swift @@ -276,6 +276,10 @@ final class AVPlayerBackend: PlayerBackend { } let startPlaying = { + #if !os(macOS) + try? AVAudioSession.sharedInstance().setActive(true) + #endif + self.setRate(self.model.currentRate) guard let item = self.model.playerItem, self.isAutoplaying(item) else { return } diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index 9868bce9..1f12fe47 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -182,6 +182,10 @@ final class MPVBackend: PlayerBackend { } let startPlaying = { + #if !os(macOS) + try? AVAudioSession.sharedInstance().setActive(true) + #endif + DispatchQueue.main.async { [weak self] in guard let self = self else { return diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 557ca41d..7b0dbe1b 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -714,6 +714,11 @@ final class PlayerModel: ObservableObject { remoteCommandCenterConfigured = true #if !os(macOS) + try? AVAudioSession.sharedInstance().setCategory( + .playback, + mode: .moviePlayback + ) + UIApplication.shared.beginReceivingRemoteControlEvents() #endif diff --git a/Shared/YatteeApp.swift b/Shared/YatteeApp.swift index 2a199f07..8233fac1 100644 --- a/Shared/YatteeApp.swift +++ b/Shared/YatteeApp.swift @@ -238,11 +238,6 @@ struct YatteeApp: App { } } #endif - - #if !os(macOS) - try? AVAudioSession.sharedInstance().setCategory(.playback) - try? AVAudioSession.sharedInstance().setActive(true) - #endif } func migrateAccounts() {