mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 02:45:03 +00:00
Expose Background Playback toggle on tvOS, default off
Surfaces the existing iOS/macOS Background Playback setting in the tvOS Playback settings, defaulting to off so audio stops when the user leaves the app via the TV button. Pauses playback on .background/.inactive when the toggle is off, regardless of audio route — the user's setting wins over AirPlay/HomePod handoff. Also auto-shows the tvOS player controls when returning to foreground so the paused state is immediately visible and actionable.
This commit is contained in:
@@ -31,6 +31,7 @@ enum TVPlayerFocusTarget: Hashable {
|
||||
struct TVPlayerView: View {
|
||||
@Environment(\.appEnvironment) private var appEnvironment
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
// MARK: - State
|
||||
|
||||
@@ -397,6 +398,13 @@ struct TVPlayerView: View {
|
||||
showControls()
|
||||
}
|
||||
}
|
||||
// When app returns to foreground (e.g. after auto-pause from background),
|
||||
// surface the controls so the user can immediately resume or navigate.
|
||||
.onChange(of: scenePhase) { oldPhase, newPhase in
|
||||
if newPhase == .active && oldPhase != .active {
|
||||
showControls()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Failure Overlays
|
||||
|
||||
Reference in New Issue
Block a user