fix(player): prevent duplicate back actions

This commit is contained in:
edde746
2026-07-11 12:59:57 +02:00
parent e07172ade4
commit 3a982c2a7a
7 changed files with 81 additions and 70 deletions
+2 -6
View File
@@ -1474,9 +1474,8 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
final isCurrentRoute = ModalRoute.of(context)?.isCurrent ?? true;
// Screen-level Focus wraps ALL phases (loading + initialized).
// - autofocus: grabs focus when no deeper child claims it.
// - onKeyEvent: self-heals when this node has primary focus (no descendant
// focused). Nav keys are only consumed in that case; otherwise they pass
// through so DirectionalFocusAction can drive dpad nav in overlay sheets.
// - onKeyEvent: owns player-level navigation after descendants have had the
// opportunity to handle local layers such as sheets and content strips.
return Focus(
focusNode: _screenFocusNode,
autofocus: isCurrentRoute,
@@ -1485,9 +1484,6 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
if (!isCurrentRoute) return KeyEventResult.ignored;
final navigationKey = classifyPlayerNavigationKey(event, isAppleTV: PlatformDetector.isAppleTV());
if (navigationKey != PlayerNavigationKey.none) {
// Descendants (controls and sheets) own staged Back while focused.
// This fallback covers loading/error phases and focus drift.
if (!node.hasPrimaryFocus) return KeyEventResult.ignored;
if (navigationKey != PlayerNavigationKey.home && PlatformDetector.isTV() && event is KeyDownEvent) {
BackKeyCoordinator.markHandled();
}