fix(player): start the TV player with its chrome down

A television raised the whole OSD and timebar on every playback start. The
chrome controller is born visible, and its auto-hide clock cannot arm until the
first frame lands, so the controls did not merely appear early: they appeared
exactly when the picture did, and then sat over the opening five seconds of
every movie and episode. The timeline is gated behind the first frame, so the
bar materialised on top of the video rather than over the loading spinner,
which is what makes it read as a pop-up rather than as chrome that was already
there.

The route now opens with no chrome on TV. Nothing is lost: the loading spinner
and buffering overlay are their own overlays, the screen focus node owns back,
and the first D-pad press raises the controls the way it already does after
every auto-hide. Pointer and touch platforms keep the chrome, where the
viewer's hand is on the surface and the title and back affordance belong over
the spinner.

Initial presentation now follows initial visibility. They were separate:
seeding only visibility would leave the route claiming its chrome was still
presented, so PlayerNavigationCoordinator would read back as "hide the chrome",
hide() would no-op against chrome that was never up, and the press would be
swallowed instead of leaving the player.

Controls that mount with the chrome already down now claim focus themselves.
Focus normally reaches them through the hide transition, and their own
autofocus cannot win it back because the screen node took it during the loading
phase. Left alone, the screen node kept primary focus and its self-heal raised
the entire OSD on the first D-pad press, which put the chrome straight back
over the picture and bypassed the transient seek and transport indicators.

Both player spinners now carry a label. They were bare progress indicators, so
a screen reader announced nothing at all while the picture was coming up, and
the TV Maestro flows had no way left to tell a loading player from a playing
one once the Pause button stopped appearing on its own.

The two TV flows are repaired to match. They waited on that button, and now
wait for the labelled spinner to clear, which cannot happen before the media is
opened. 05 additionally reaches Search by D-pad rather than a percentage
coordinate, because a tap flips InputModeTracker to pointer mode and collapses
the rail it is aiming at, and it gates on the play-next prompt's own Cancel
action: "Next Episode" is also the credits skip button, so the old assertion
could pass without the prompt ever opening.

close #1765
This commit is contained in:
edde746
2026-08-02 11:45:27 +02:00
parent 35061f9f68
commit bbed260169
37 changed files with 544 additions and 22 deletions
@@ -250,7 +250,7 @@ extension _PlexVideoControlsVisibilityMethods on _PlexVideoControlsState {
_controlsOpaque = false;
if (_currentMarker != null) _skipButtonDismissed = true;
});
_reclaimFocusAfterControlsHide();
_claimHiddenChromeFocus();
} else if (visibilityChanged) {
// The timeline is about to take over held-key seeking; commit whatever
// the hidden-chrome burst accumulated so it can't rebase from a stale
@@ -280,7 +280,11 @@ extension _PlexVideoControlsVisibilityMethods on _PlexVideoControlsState {
}
}
void _reclaimFocusAfterControlsHide() {
/// Park focus on the player surface so the hidden-chrome key layer owns the
/// remote. Without this the screen node keeps primary focus and its
/// self-heal raises the whole chrome on the first actionable key, which is
/// what the transient seek and transport indicators exist to avoid.
void _claimHiddenChromeFocus() {
final sheetOpen = OverlaySheetController.maybeOf(context)?.isOpen ?? false;
if (sheetOpen) return;
_focusNode.requestFocus();
@@ -295,7 +299,7 @@ extension _PlexVideoControlsVisibilityMethods on _PlexVideoControlsState {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted || !widget.chromeController.controlsVisible) return;
// Never steal focus from an open sheet (same rule as
// _reclaimFocusAfterControlsHide).
// _claimHiddenChromeFocus).
if (OverlaySheetController.maybeOf(context)?.isOpen ?? false) return;
switch (target) {
case PlayerChromeFocusTarget.playPause:
@@ -12,10 +12,12 @@ enum PlayerChromeFocusTarget { playPause, timeline }
/// Owns video-player chrome visibility and auto-hide policy for one player route.
class PlayerChromeController extends ChangeNotifier implements ValueListenable<bool> {
PlayerChromeController({this._controlsVisible = true});
PlayerChromeController({bool initiallyVisible = true})
: _controlsVisible = initiallyVisible,
_controlsPresented = initiallyVisible;
bool _controlsVisible;
bool _controlsPresented = true;
bool _controlsPresented;
bool _contentStripVisible = false;
bool _playing = false;
bool _hasFirstFrame = true;
@@ -851,6 +851,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
_rateSubscription = widget.player.streams.rate.listen(_onRateChanged);
_loadPlaybackExtras();
_focusPlayPauseIfKeyboardMode();
// A route that opened with no chrome never ran the hide transition that
// normally hands focus down here, and this Focus autofocuses too late to
// win it: the screen node claimed it during the loading phase.
if (!widget.chromeController.controlsVisible) _claimHiddenChromeFocus();
if (PlatformDetector.isMobile(context) && !PlatformDetector.isTV()) {
_refreshDeviceAdjustmentValues();
}