feat(player): toggle playback on a two-finger tap without raising the chrome

A touch viewer had to raise the chrome to pause, which dims the picture and
covers the subtitle line they were trying to finish reading. A two-finger tap
now toggles playback with the chrome left down, so the frame that pauses is the
frame that was on screen. It fires the moment the chord resolves, in every
player state.

The two-finger double tap no longer resets the video zoom. Keeping it would mean
holding this toggle back for the double-tap window before acting, and pausing
late is pausing on the wrong frame. Zoom reset stays in the video settings sheet,
its presets and the keyboard shortcut, and pinching back to 100% now snaps
exactly within three percent so touch has a one-gesture path too.

Both chord actions share _mobileTouchGesturesAllowed, so the chord is inert
under screen lock, in PiP and while the content strip is open; the zoom reset
previously fired straight through a locked screen.

close #1505
This commit is contained in:
edde746
2026-08-03 00:04:03 +02:00
parent 9c08c78f6d
commit fb0613e3db
10 changed files with 645 additions and 152 deletions
+23
View File
@@ -21,6 +21,29 @@ class VideoFilterManager {
static const double maxZoomScale = 2.0;
static const double zoomStep = 0.01;
/// How close a pinch has to get to 100%, in whole percent, before it snaps
/// there exactly.
///
/// [normalizeZoomScale] rounds to whole percent, so an unaided pinch has to
/// land inside half a percent of 1.0 to undo itself — in practice it leaves
/// the picture at 99% or 101% and the viewer cannot tell why it still looks
/// cropped. A detent makes the pinch a reliable inverse of itself.
///
/// Deliberately applied to the pinch handler only, never inside
/// [normalizeZoomScale]: [zoomStep] is 1%, so a global detent would trap the
/// keyboard and slider paths at 1.0 with no way to step out.
static const int pinchZoomResetDetentPercent = 3;
/// Snaps a pinch-derived [scale] to exactly 1.0 inside the detent.
///
/// Compared in whole percent like [normalizeZoomScale], not in raw doubles:
/// `(0.97 - 1.0).abs()` is 0.030000000000000027, so a float comparison against
/// a 0.03 band drops the very boundary it is meant to include.
static double snapPinchZoomScale(double scale) {
final percent = (scale * 100).round();
return (percent - 100).abs() <= pinchZoomResetDetentPercent ? 1.0 : scale;
}
final Player player;
/// BoxFit mode state: 0=contain (letterbox), 1=cover (fill screen), 2=fill (stretch)