mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user