From ea57378b004b52a1b5249a50967b468fbe0f9078 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 20 Sep 2026 23:49:35 +0200 Subject: [PATCH] Keep Apple TV awake during audio-only playback Since b08974f4 audio-only playback re-enabled the idle timer on every platform. On tvOS idle means screensaver and then device sleep, which suspends the app, stops playback, and turns the TV off over HDMI-CEC. Always prevent sleep while playing on tvOS; iOS and macOS still let the screen sleep in audio mode. --- Yattee/Services/Player/PlayerService.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Yattee/Services/Player/PlayerService.swift b/Yattee/Services/Player/PlayerService.swift index d8448cb9..d8c188a8 100644 --- a/Yattee/Services/Player/PlayerService.swift +++ b/Yattee/Services/Player/PlayerService.swift @@ -636,12 +636,20 @@ final class PlayerService { /// Reconciles sleep prevention with what is actually on screen: display sleep /// is only prevented when a video track is rendered. Audio-only playback /// lets the screen sleep normally. + /// + /// tvOS is the exception: idle there means screensaver and then device sleep, + /// which suspends the app, stops playback, and powers the TV off over CEC. + /// Audio-only playback must keep the idle timer disabled as well. private func updateSleepPrevention() { + #if os(tvOS) + sleepPreventionService.preventSleep() + #else if state.currentStream?.isAudioOnly == true { sleepPreventionService.allowSleep() } else { sleepPreventionService.preventSleep() } + #endif } /// Pauses playback.