I'm developing a tvOS application using SwiftUI, and I have a custom video player presented using fullScreenCover.
.fullScreenCover(isPresented: $isPlayerPresented) {
PlayerView()
}
I would like to implement the same kind of behavior commonly seen in video players:
- The player is presented full screen.
- When the playback controls are visible, pressing the Siri Remote Back button should hide the controls.
- The player should remain presented.
- Only when the controls are already hidden should pressing Back dismiss the player.
However, I am unable to intercept the Back button before the fullScreenCover is dismissed.
I have tried several approaches, including:
.onExitCommand {
// Handle Back
}
and handling UIPress / .menu events through UIKit.
The problem is that when the Siri Remote Back button is pressed while the view is presented using fullScreenCover, the fullScreenCover is dismissed directly. My custom view does not appear to be able to prevent the dismissal.
I also tried placing a custom UIView / UITapGestureRecognizer inside the fullScreenCover to intercept the remote button event, but the presentation is still dismissed.
According to the SwiftUI documentation, onExitCommand responds to the tvOS exit command generated by the Menu button, but it does not appear to provide a way to prevent the system from dismissing a fullScreenCover in response to the Siri Remote Back button.
I also noticed that interactiveDismissDisabled(_:) does not appear to provide a solution for this particular tvOS behavior.
My questions
- Is the Siri Remote Back button expected to automatically dismiss a SwiftUI
fullScreenCoveron tvOS? - Is there a supported API to intercept the Back button before the
fullScreenCoveris dismissed? - Is there a way to tell SwiftUI that a
fullScreenCovershould not be dismissed by the Siri Remote Back button? - If
fullScreenCoveris not intended for this use case, what is the recommended way to implement a custom full-screen video player that needs to control Back-button behavior?
The desired behavior is essentially:
Back button
↓
Are playback controls visible?
├── Yes → hide controls, keep player presented
└── No → dismiss player
I would appreciate any guidance on the intended tvOS API or recommended architecture for implementing this behavior.
Thanks!