From 332d5dc38c911aa02734a32e3cc95d67a20d475b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 20 Aug 2023 21:01:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=95=E9=83=A8=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/setting/play_setting.dart | 30 ++++++++++++++++++- lib/plugin/pl_player/index.dart | 2 ++ .../models/bottom_progress_behavior.dart | 23 ++++++++++++++ lib/plugin/pl_player/view.dart | 15 +++++++++- lib/utils/storage.dart | 1 + 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 lib/plugin/pl_player/models/bottom_progress_behavior.dart diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index 6f160f08..524b014a 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/models/video/play/quality.dart'; -import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart'; +import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/utils/storage.dart'; import 'widgets/switch_item.dart'; @@ -19,6 +19,7 @@ class _PlaySettingState extends State { late dynamic defaultAudioQa; late dynamic defaultDecode; late int defaultFullScreenMode; + late int defaultBtmProgressBehavior; @override void initState() { @@ -31,6 +32,8 @@ class _PlaySettingState extends State { defaultValue: VideoDecodeFormats.values.last.code); defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode, defaultValue: FullScreenMode.values.first.code); + defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior, + defaultValue: BtmProgresBehavior.values.first.code); } @override @@ -163,6 +166,31 @@ class _PlaySettingState extends State { ], ), ), + ListTile( + dense: false, + title: Text('底部进度条展示', style: titleStyle), + subtitle: Text( + '当前展示方式:${BtmProgresBehaviorCode.fromCode(defaultBtmProgressBehavior)!.description}', + style: subTitleStyle, + ), + trailing: PopupMenuButton( + initialValue: defaultBtmProgressBehavior, + icon: const Icon(Icons.more_vert_outlined, size: 22), + onSelected: (item) { + defaultBtmProgressBehavior = item; + setting.put(SettingBoxKey.btmProgressBehavior, item); + setState(() {}); + }, + itemBuilder: (BuildContext context) => [ + for (var i in BtmProgresBehavior.values) ...[ + PopupMenuItem( + value: i.code, + child: Text(i.description), + ), + ] + ], + ), + ), ], ), ); diff --git a/lib/plugin/pl_player/index.dart b/lib/plugin/pl_player/index.dart index 05cdffad..9d711264 100644 --- a/lib/plugin/pl_player/index.dart +++ b/lib/plugin/pl_player/index.dart @@ -7,6 +7,8 @@ export './models/play_status.dart'; export './models/data_status.dart'; export './widgets/common_btn.dart'; export './models/play_speed.dart'; +export './models/fullscreen_mode.dart'; +export './models/bottom_progress_behavior.dart'; export './widgets/app_bar_ani.dart'; export './utils/fullscreen.dart'; export './utils.dart'; diff --git a/lib/plugin/pl_player/models/bottom_progress_behavior.dart b/lib/plugin/pl_player/models/bottom_progress_behavior.dart new file mode 100644 index 00000000..c632669c --- /dev/null +++ b/lib/plugin/pl_player/models/bottom_progress_behavior.dart @@ -0,0 +1,23 @@ +// ignore: camel_case_types +enum BtmProgresBehavior { + alwaysShow, + alwaysHide, + onlyShowFullScreen, +} + +extension BtmProgresBehaviorDesc on BtmProgresBehavior { + String get description => ['始终展示', '始终隐藏', '仅全屏时展示'][index]; +} + +extension BtmProgresBehaviorCode on BtmProgresBehavior { + static final List _codeList = [0, 1, 2]; + int get code => _codeList[index]; + + static BtmProgresBehavior? fromCode(int code) { + final index = _codeList.indexOf(code); + if (index != -1) { + return BtmProgresBehavior.values[index]; + } + return null; + } +} diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 170d9614..7ba5de18 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -18,6 +18,7 @@ import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:screen_brightness/screen_brightness.dart'; +import 'models/bottom_progress_behavior.dart'; import 'utils/fullscreen.dart'; import 'widgets/app_bar_ani.dart'; import 'widgets/backward_seek.dart'; @@ -67,6 +68,7 @@ class _PLVideoPlayerState extends State Box setting = GStrorage.setting; late FullScreenMode mode; + late int defaultBtmProgressBehavior; void onDoubleTapSeekBackward() { setState(() { @@ -87,6 +89,8 @@ class _PLVideoPlayerState extends State vsync: this, duration: const Duration(milliseconds: 300)); videoController = widget.controller.videoController!; widget.controller.headerControl = widget.headerControl; + defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior, + defaultValue: BtmProgresBehavior.values.first.code); Future.microtask(() async { try { @@ -203,7 +207,7 @@ class _PLVideoPlayerState extends State systemOverlayStyle: SystemUiOverlayStyle.light, ), body: SafeArea( - bottom: true, + bottom: false, child: PLVideoPlayer( controller: _, headerControl: _.headerControl, @@ -626,6 +630,15 @@ class _PLVideoPlayerState extends State final int value = _.sliderPosition.value.inSeconds; final int max = _.duration.value.inSeconds; final int buffer = _.buffered.value.inSeconds; + if (defaultBtmProgressBehavior == + BtmProgresBehavior.alwaysHide.code) { + return Container(); + } + if (defaultBtmProgressBehavior == + BtmProgresBehavior.onlyShowFullScreen.code && + !_.isFullScreen.value) { + return Container(); + } if (value > max || max <= 0) { return Container(); } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 02daa7f2..3f33105b 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -109,6 +109,7 @@ class SettingBoxKey { static const String blackMidsList = 'blackMidsList'; static const String autoUpdate = 'autoUpdate'; + static const String btmProgressBehavior = 'btmProgressBehavior'; } class LocalCacheKey {