Keep tvOS player controls visible on pause via on-screen button

Route the on-screen play/pause button through handlePlayPause() so it
follows the same visibility and auto-hide timer logic as the Siri Remote
hardware button: timer stops when paused (controls stay pinned) and
restarts on resume.
This commit is contained in:
Arkadiusz Fal
2026-05-09 11:00:04 +02:00
parent 7c1549ed35
commit b6c3f0e71b
2 changed files with 6 additions and 1 deletions

View File

@@ -21,6 +21,10 @@ struct TVPlayerControlsView: View {
let onShowComments: () -> Void let onShowComments: () -> Void
let onShowDebug: () -> Void let onShowDebug: () -> Void
let onClose: () -> Void let onClose: () -> Void
/// Called when the on-screen play/pause button is tapped. Parent routes
/// through `handlePlayPause()` so visibility/auto-hide timer behave
/// consistently with the Siri Remote's hardware Play/Pause button.
let onTogglePlayPause: () -> Void
/// Called when scrubbing state changes - parent should stop auto-hide timer when true /// Called when scrubbing state changes - parent should stop auto-hide timer when true
var onScrubbingChanged: ((Bool) -> Void)? var onScrubbingChanged: ((Bool) -> Void)?
/// Pending target time for the bar's accumulating remote-seek flow (arrow /// Pending target time for the bar's accumulating remote-seek flow (arrow
@@ -269,7 +273,7 @@ struct TVPlayerControlsView: View {
Button { Button {
playPauseTapCount += 1 playPauseTapCount += 1
playerService?.togglePlayPause() onTogglePlayPause()
} label: { } label: {
Image(systemName: playPauseIcon) Image(systemName: playPauseIcon)
.font(.system(size: 32, weight: .semibold)) .font(.system(size: 32, weight: .semibold))

View File

@@ -232,6 +232,7 @@ struct TVPlayerView: View {
onShowComments: { showDetailsPanel(tab: .comments) }, onShowComments: { showDetailsPanel(tab: .comments) },
onShowDebug: { showDebugOverlay() }, onShowDebug: { showDebugOverlay() },
onClose: { closeVideo() }, onClose: { closeVideo() },
onTogglePlayPause: { handlePlayPause() },
onScrubbingChanged: { scrubbing in onScrubbingChanged: { scrubbing in
isScrubbing = scrubbing isScrubbing = scrubbing
if scrubbing { if scrubbing {