diff --git a/lib/screens/video_player/parts/build.dart b/lib/screens/video_player/parts/build.dart index 99848cce..25ab91d3 100644 --- a/lib/screens/video_player/parts/build.dart +++ b/lib/screens/video_player/parts/build.dart @@ -2,7 +2,8 @@ part of '../../video_player_screen.dart'; extension _VideoPlayerBuildMethods on VideoPlayerScreenState { static const double _videoLayoutSizeTolerance = 0.1; - static const double _pinchZoomActivationThreshold = 0.015; + static const double _pinchZoomActivationThreshold = 0.06; + static const int _pinchZoomActivationUpdateThreshold = 3; bool _isSameVideoLayoutSize(Size a, Size b) { return (a.width - b.width).abs() <= _videoLayoutSizeTolerance && @@ -143,14 +144,15 @@ extension _VideoPlayerBuildMethods on VideoPlayerScreenState { final filterManager = _videoFilterManager; if (filterManager == null || _isPinchZooming) return; - _ambientLightingService?.disable(); _isPinchZooming = true; + _pinchZoomActivationUpdateCount = 0; _pinchZoomChanged = false; _pinchStartZoomScale = filterManager.zoomScale; } void _clearMobileZoomGesture() { _isPinchZooming = false; + _pinchZoomActivationUpdateCount = 0; _pinchZoomChanged = false; _pinchStartZoomScale = null; } @@ -179,10 +181,23 @@ extension _VideoPlayerBuildMethods on VideoPlayerScreenState { final startZoom = _pinchStartZoomScale; final filterManager = _videoFilterManager; if (!_isPinchZooming || startZoom == null || filterManager == null) return; - if ((details.scale - 1.0).abs() <= _pinchZoomActivationThreshold && !_pinchZoomChanged) return; + final nextZoomScale = VideoFilterManager.normalizeZoomScale(startZoom * details.scale); - _pinchZoomChanged = true; - filterManager.setZoomScale(startZoom * details.scale); + if (!_pinchZoomChanged) { + if ((details.scale - 1.0).abs() <= _pinchZoomActivationThreshold) { + _pinchZoomActivationUpdateCount = 0; + return; + } + + _pinchZoomActivationUpdateCount++; + if (_pinchZoomActivationUpdateCount < _pinchZoomActivationUpdateThreshold) return; + if (nextZoomScale == filterManager.zoomScale) return; + + _pinchZoomChanged = true; + _ambientLightingService?.disable(); + } + + filterManager.setZoomScale(nextZoomScale); }, onScaleEnd: (details) { if (!isMobile) return; diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 8e94399e..e7b6ae69 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -411,6 +411,7 @@ class VideoPlayerScreenState extends State with WidgetsBindin Player? _lastVideoLayoutPlayer; bool _videoLayoutUpdateScheduled = false; double? _pinchStartZoomScale; + int _pinchZoomActivationUpdateCount = 0; bool _isPinchZooming = false; bool _pinchZoomChanged = false; final EpisodeNavigationService _episodeNavigation = EpisodeNavigationService();