feat: show the controls when play/pause comes from outside the controls - #957
Open
Ortes wants to merge 4 commits into
Open
feat: show the controls when play/pause comes from outside the controls#957Ortes wants to merge 4 commits into
Ortes wants to merge 4 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 butMaterialDesktopControlsgives no visual feedback. Pressing space (which goes through the controls' own_playPause) reveals the controls; the media key does not.With this change any
isPlayingflip reveals the controls and restarts the hide timer, so the state change is always visible and the controls auto-hide again afterhideControlsTimer.How
_updateState(already registered as a listener on theVideoPlayerController) compares the incomingcontroller.value.isPlayingagainst 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 intovalue.isPlaying(isPlayingStateUpdate), so this covers web media keys, ExoPlayer'sonIsPlayingChanged, iOS Control Center, etc.Tests
test/external_playpause_test.dartdrives 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 fullflutter testsuite are clean.