From 9255f3cb698e3cb3ca32068851e710537415699a Mon Sep 17 00:00:00 2001 From: orz12 Date: Mon, 22 Apr 2024 20:16:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8B=86=E5=88=86=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E4=B8=8EAudioService=E5=9C=A8=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E8=A1=8C=E4=B8=BA=E7=9A=84=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 | 12 +++++++++--- lib/pages/video/detail/widgets/header_control.dart | 4 ++-- lib/plugin/pl_player/controller.dart | 12 ++++++------ lib/plugin/pl_player/view.dart | 4 ++-- lib/utils/storage.dart | 1 + 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index 2f75ebe8..547b493f 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -140,20 +140,20 @@ class _PlaySettingState extends State { const SetSwitchItem( title: '后台播放', subTitle: '进入后台时继续播放', - setKey: SettingBoxKey.enableBackgroundPlay, + setKey: SettingBoxKey.continuePlayInBackground, defaultVal: true, ), if (Platform.isAndroid) SetSwitchItem( title: '后台画中画', - subTitle: '进入后台时以小窗形式(PiP)播放,建议同时开启【后台播放】,避免没有暂停按钮', + subTitle: '进入后台时以小窗形式(PiP)播放', setKey: SettingBoxKey.autoPiP, defaultVal: false, callFn: (val) { if (val && !setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true)) { - SmartDialog.showToast('建议开启后台播放'); + SmartDialog.showToast('建议开启后台音频服务'); } }), if (Platform.isAndroid) @@ -227,6 +227,12 @@ class _PlaySettingState extends State { } }, ), + const SetSwitchItem( + title: '后台音频服务', + subTitle: '避免画中画没有播放暂停功能', + setKey: SettingBoxKey.enableBackgroundPlay, + defaultVal: true, + ), ], ), ); diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 5fa6ac52..3077b1d6 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1313,7 +1313,7 @@ class _HeaderControlState extends State { ), const SizedBox(height: 10), const Text( - '建议开启【后台播放】功能\n' + '建议开启【后台音频服务】\n' '避免画中画没有暂停按钮', style: TextStyle(fontSize: 12.5, height: 1.5)), @@ -1333,7 +1333,7 @@ class _HeaderControlState extends State { SmartDialog.showToast("请重新载入本页面刷新"); // Get.back(); }, - child: const Text('启用后台播放(推荐)')), + child: const Text('启用后台音频服务')), const SizedBox(width: 10), TextButton( style: ButtonStyle( diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index f9f110d0..5d662191 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -87,7 +87,7 @@ class PlPlayerController { late StreamSubscription _dataListenerForEnterFullscreen; /// 后台播放 - final Rx _backgroundPlay = false.obs; + final Rx _continuePlayInBackground = false.obs; /// // ignore: prefer_final_fields @@ -209,7 +209,7 @@ class PlPlayerController { Rx get videoFitDEsc => _videoFitDesc; /// 后台播放 - Rx get backgroundPlay => _backgroundPlay; + Rx get continuePlayInBackground => _continuePlayInBackground; /// 是否长按倍速 Rx get doubleSpeedStatus => _doubleSpeedStatus; @@ -311,8 +311,8 @@ class PlPlayerController { enableAutoLongPressSpeed = setting .get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false); // 后台播放 - _backgroundPlay.value = - setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true); + _continuePlayInBackground.value = + setting.get(SettingBoxKey.continuePlayInBackground, defaultValue: true); if (!enableAutoLongPressSpeed) { _longPressSpeed.value = videoStorage .get(VideoBoxKey.longPressSpeedDefault, defaultValue: 3.0); @@ -980,8 +980,8 @@ class PlPlayerController { /// 设置后台播放 Future setBackgroundPlay(bool val) async { - _backgroundPlay.value = val; - setting.put(SettingBoxKey.enableBackgroundPlay, val); + _continuePlayInBackground.value = val; + setting.put(SettingBoxKey.continuePlayInBackground, val); videoPlayerServiceHandler.revalidateSetting(); } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 2720fbb7..882efd61 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -496,10 +496,10 @@ class _PLVideoPlayerState extends State children: [ Obx( () => Video( - key: ValueKey('${_.videoFit.value}${_.backgroundPlay.value}'), + key: ValueKey('${_.videoFit.value}${_.continuePlayInBackground.value}'), controller: videoController, controls: NoVideoControls, - pauseUponEnteringBackgroundMode: !_.backgroundPlay.value, + pauseUponEnteringBackgroundMode: !_.continuePlayInBackground.value, resumeUponEnteringForegroundMode: true, subtitleViewConfiguration: const SubtitleViewConfiguration( style: subTitleStyle, diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 7239c876..d1377df3 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -108,6 +108,7 @@ class SettingBoxKey { fullScreenGestureReverse = 'fullScreenGestureReverse', enableShowDanmaku = 'enableShowDanmaku', enableBackgroundPlay = 'enableBackgroundPlay', + continuePlayInBackground = 'continuePlayInBackground', /// 隐私 blackMidsList = 'blackMidsList',