基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat: desktop touchscreen (#2236)
Predidit1a517cfc44da
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex 29edb173..2903b82d 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';import 'package:kazumi/pages/player/player_item_panel.dart';import 'package:kazumi/pages/player/player_panel_hold.dart';+import 'package:kazumi/pages/player/player_pointer_interaction.dart';import 'package:kazumi/pages/player/player_screenshot_feedback_overlay.dart';import 'package:kazumi/pages/player/smallest_player_item_panel.dart';import 'package:kazumi/utils/constants.dart';@@ -127,6 +128,8 @@ class _PlayerItemState extends State<PlayerItem>Timer? _adjustmentHudHideTimer;final Set<PlayerPanelHold> _playerPanelHolds = <PlayerPanelHold>{};PlayerPanelHold? _progressBarDragHold;+ PointerDeviceKind? _lastTapPointerKind;+ PointerDeviceKind? _lastDoubleTapPointerKind;double lastVolume = 0;@@ -416,24 +419,35 @@ class _PlayerItemState extends State<PlayerItem>}}- void _handleTap() {- if (isDesktop()) {- playerController.playOrPause();+ void _toggleVideoController() {+ if (playerController.panel.showVideoController) {+ hideVideoController();} else {- if (playerController.panel.showVideoController) {- hideVideoController();- } else {- displayVideoController();- }+ displayVideoController();+ }+ }++ void _handleTap(PointerDeviceKind? pointerKind) {+ if (shouldToggleControllerOnPrimaryTap(+ isDesktop: isDesktop(),+ pointerKind: pointerKind,+ )) {+ _toggleVideoController();+ return;}+ playerController.playOrPause();}- void _handleDoubleTap() {- if (isDesktop() && !videoPageController.isPip) {+ void _handleDoubleTap(PointerDeviceKind? pointerKind) {+ if (shouldToggleFullscreenOnDoubleTap(+ isDesktop: isDesktop(),+ isPip: videoPageController.isPip,+ pointerKind: pointerKind,+ )) {handleFullscreen();- } else {- playerController.playOrPause();+ return;}+ playerController.playOrPause();}void _handleMouseScroller() {@@ -1808,13 +1822,30 @@ class _PlayerItemState extends State<PlayerItem>): Container(),GestureDetector(+ onTapDown: (details) {+ _lastTapPointerKind = details.kind;+ },onTap: () {- _handleTap();+ _handleTap(_lastTapPointerKind);+ _lastTapPointerKind = null;+ },+ onTapCancel: () {+ _lastTapPointerKind = null;},+ onDoubleTapDown: (playerController.panel.lockPanel)+ ? null+ : (details) {+ _lastDoubleTapPointerKind = details.kind;+ },onDoubleTap: (playerController.panel.lockPanel)? null: () {- _handleDoubleTap();+ _handleDoubleTap(+ _lastDoubleTapPointerKind ??+ _lastTapPointerKind,+ );+ _lastDoubleTapPointerKind = null;+ _lastTapPointerKind = null;},onLongPressStart: (_) {if (playerController.panel.lockPanel) {diff --git a/lib/pages/player/player_pointer_interaction.dart b/lib/pages/player/player_pointer_interaction.dartnew file mode 100644index 00000000..2a36f603--- /dev/null+++ b/lib/pages/player/player_pointer_interaction.dart@@ -0,0 +1,22 @@+import 'package:flutter/gestures.dart';++bool isTouchLikePointer(PointerDeviceKind? pointerKind) {+ return pointerKind == PointerDeviceKind.touch ||+ pointerKind == PointerDeviceKind.stylus ||+ pointerKind == PointerDeviceKind.invertedStylus;+}++bool shouldToggleControllerOnPrimaryTap({+ required bool isDesktop,+ required PointerDeviceKind? pointerKind,+}) {+ return !isDesktop || isTouchLikePointer(pointerKind);+}++bool shouldToggleFullscreenOnDoubleTap({+ required bool isDesktop,+ required bool isPip,+ required PointerDeviceKind? pointerKind,+}) {+ return isDesktop && !isPip && !isTouchLikePointer(pointerKind);+}