Skip to content

feat: show the controls when play/pause comes from outside the controls - #957

Open
Ortes wants to merge 4 commits into
fluttercommunity:masterfrom
Ortes:feat/external-playpause-controls
Open

feat: show the controls when play/pause comes from outside the controls#957
Ortes wants to merge 4 commits into
fluttercommunity:masterfrom
Ortes:feat/external-playpause-controls

Conversation

@Ortes

@Ortes Ortes commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

When playback is toggled from outside the controls — hardware media keys (▶⏸/F8, handled natively by the browser on web), Android headset/notification controls, the MediaSession API, or the embedding app driving the VideoPlayerController — the video starts/stops but MaterialDesktopControls gives no visual feedback. Pressing space (which goes through the controls' own _playPause) reveals the controls; the media key does not.

With this change any isPlaying flip reveals the controls and restarts the hide timer, so the state change is always visible and the controls auto-hide again after hideControlsTimer.

How

_updateState (already registered as a listener on the VideoPlayerController) compares the incoming controller.value.isPlaying against the previous snapshot _latestValue — which now gets an initializer so its first read can't throw — and calls the existing _cancelAndRestartTimer() on a flip. No new state, no platform-specific code: every platform implementation funnels external play/pause into value.isPlaying (isPlayingStateUpdate), so this covers web media keys, ExoPlayer's onIsPlayingChanged, iOS Control Center, etc.

Tests

test/external_playpause_test.dart drives an externally-mutated controller and covers: reveal + auto-hide on external play, reveal + auto-hide on external pause, and no reveal on position-only updates.

dart format, dart analyze lib test, and the full flutter test suite are clean.

Ortes added 2 commits July 12, 2026 07:43
Hardware media keys (play/pause handled natively by the browser) and
MediaSession toggle the video element directly: playback changes but the
controls give no visual feedback. Watch for isPlaying flips in
_updateState and mirror _playPause: reveal-and-hold on pause,
reveal-then-autohide on resume.
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.04%. Comparing base (69a8fc7) to head (7f3bdce).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #957      +/-   ##
==========================================
+ Coverage   43.82%   46.04%   +2.22%     
==========================================
  Files          21       21              
  Lines        1602     1605       +3     
==========================================
+ Hits          702      739      +37     
+ Misses        900      866      -34     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Ortes added 2 commits July 12, 2026 08:28
Compare against _latestValue (now initialized from the controller) instead
of a dedicated field, and drop the pause special-case: the controls reveal
and auto-hide the same way for both directions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant