From 516877fb1fe22fe7990c8e60086118f3881a8273 Mon Sep 17 00:00:00 2001 From: orz12 Date: Wed, 14 Feb 2024 09:42:50 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=85=A8=E5=B1=8F=E6=89=8B=E5=8A=BF?= =?UTF-8?q?=E5=8F=8D=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/setting/play_setting.dart | 6 ++++++ lib/plugin/pl_player/view.dart | 21 +++++++++++++-------- lib/utils/storage.dart | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index e8763aa55..02aba8778 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -157,6 +157,12 @@ class _PlaySettingState extends State { setKey: SettingBoxKey.enableQuickDouble, defaultVal: true, ), + const SetSwitchItem( + title: '全屏手势反向', + subTitle: '默认播放器中部向上滑动进入全屏,向下退出\n开启后向下全屏,向上退出', + setKey: SettingBoxKey.fullScreenGestureReverse, + defaultVal: false, + ), const SetSwitchItem( title: '弹幕开关', subTitle: '展示弹幕', diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 8a6e6dee7..bdf5d2c80 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -72,6 +72,7 @@ class _PLVideoPlayerState extends State late FullScreenMode mode; late int defaultBtmProgressBehavior; late bool enableQuickDouble; + late bool fullScreenGestureReverse; late bool enableBackgroundPlay; // 用于记录上一次全屏切换手势触发时间,避免误触 @@ -126,6 +127,8 @@ class _PLVideoPlayerState extends State defaultValue: BtmProgresBehavior.values.first.code); enableQuickDouble = setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true); + fullScreenGestureReverse = setting.get(SettingBoxKey.fullScreenGestureReverse, + defaultValue: false); enableBackgroundPlay = setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: false); Future.microtask(() async { @@ -522,18 +525,20 @@ class _PLVideoPlayerState extends State // 全屏 final double dy = details.delta.dy; const double threshold = 7.0; // 滑动阈值 + void fullScreenTrigger() async { + lastFullScreenToggleTime = DateTime.now(); + await widget.controller.triggerFullScreen(); + } if (dy > _distance && dy > threshold) { - if (_.isFullScreen.value) { - lastFullScreenToggleTime = DateTime.now(); - // 下滑退出全屏 - await widget.controller.triggerFullScreen(status: false); + // 下滑退出全屏 + if (_.isFullScreen.value ^ fullScreenGestureReverse) { + fullScreenTrigger(); } _distance = 0.0; } else if (dy < _distance && dy < -threshold) { - if (!_.isFullScreen.value) { - lastFullScreenToggleTime = DateTime.now(); - // 上滑进入全屏 - await widget.controller.triggerFullScreen(); + // 上划进入全屏 + if (!_.isFullScreen.value ^ fullScreenGestureReverse) { + fullScreenTrigger(); } _distance = 0.0; } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 2bc6f7cba..69cb62612 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -97,6 +97,7 @@ class SettingBoxKey { // youtube 双击快进快退 enableQuickDouble = 'enableQuickDouble', + fullScreenGestureReverse = 'fullScreenGestureReverse', enableShowDanmaku = 'enableShowDanmaku', enableBackgroundPlay = 'enableBackgroundPlay',