mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 拆分后台播放与AudioService在后台行为的设置
This commit is contained in:
@@ -140,20 +140,20 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '后台播放',
|
title: '后台播放',
|
||||||
subTitle: '进入后台时继续播放',
|
subTitle: '进入后台时继续播放',
|
||||||
setKey: SettingBoxKey.enableBackgroundPlay,
|
setKey: SettingBoxKey.continuePlayInBackground,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
if (Platform.isAndroid)
|
if (Platform.isAndroid)
|
||||||
SetSwitchItem(
|
SetSwitchItem(
|
||||||
title: '后台画中画',
|
title: '后台画中画',
|
||||||
subTitle: '进入后台时以小窗形式(PiP)播放,建议同时开启【后台播放】,避免没有暂停按钮',
|
subTitle: '进入后台时以小窗形式(PiP)播放',
|
||||||
setKey: SettingBoxKey.autoPiP,
|
setKey: SettingBoxKey.autoPiP,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
callFn: (val) {
|
callFn: (val) {
|
||||||
if (val &&
|
if (val &&
|
||||||
!setting.get(SettingBoxKey.enableBackgroundPlay,
|
!setting.get(SettingBoxKey.enableBackgroundPlay,
|
||||||
defaultValue: true)) {
|
defaultValue: true)) {
|
||||||
SmartDialog.showToast('建议开启后台播放');
|
SmartDialog.showToast('建议开启后台音频服务');
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
if (Platform.isAndroid)
|
if (Platform.isAndroid)
|
||||||
@@ -227,6 +227,12 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '后台音频服务',
|
||||||
|
subTitle: '避免画中画没有播放暂停功能',
|
||||||
|
setKey: SettingBoxKey.enableBackgroundPlay,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1313,7 +1313,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Text(
|
const Text(
|
||||||
'建议开启【后台播放】功能\n'
|
'建议开启【后台音频服务】\n'
|
||||||
'避免画中画没有暂停按钮',
|
'避免画中画没有暂停按钮',
|
||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 12.5, height: 1.5)),
|
TextStyle(fontSize: 12.5, height: 1.5)),
|
||||||
@@ -1333,7 +1333,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
SmartDialog.showToast("请重新载入本页面刷新");
|
SmartDialog.showToast("请重新载入本页面刷新");
|
||||||
// Get.back();
|
// Get.back();
|
||||||
},
|
},
|
||||||
child: const Text('启用后台播放(推荐)')),
|
child: const Text('启用后台音频服务')),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class PlPlayerController {
|
|||||||
late StreamSubscription<DataStatus> _dataListenerForEnterFullscreen;
|
late StreamSubscription<DataStatus> _dataListenerForEnterFullscreen;
|
||||||
|
|
||||||
/// 后台播放
|
/// 后台播放
|
||||||
final Rx<bool> _backgroundPlay = false.obs;
|
final Rx<bool> _continuePlayInBackground = false.obs;
|
||||||
|
|
||||||
///
|
///
|
||||||
// ignore: prefer_final_fields
|
// ignore: prefer_final_fields
|
||||||
@@ -209,7 +209,7 @@ class PlPlayerController {
|
|||||||
Rx<String> get videoFitDEsc => _videoFitDesc;
|
Rx<String> get videoFitDEsc => _videoFitDesc;
|
||||||
|
|
||||||
/// 后台播放
|
/// 后台播放
|
||||||
Rx<bool> get backgroundPlay => _backgroundPlay;
|
Rx<bool> get continuePlayInBackground => _continuePlayInBackground;
|
||||||
|
|
||||||
/// 是否长按倍速
|
/// 是否长按倍速
|
||||||
Rx<bool> get doubleSpeedStatus => _doubleSpeedStatus;
|
Rx<bool> get doubleSpeedStatus => _doubleSpeedStatus;
|
||||||
@@ -311,8 +311,8 @@ class PlPlayerController {
|
|||||||
enableAutoLongPressSpeed = setting
|
enableAutoLongPressSpeed = setting
|
||||||
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
||||||
// 后台播放
|
// 后台播放
|
||||||
_backgroundPlay.value =
|
_continuePlayInBackground.value =
|
||||||
setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true);
|
setting.get(SettingBoxKey.continuePlayInBackground, defaultValue: true);
|
||||||
if (!enableAutoLongPressSpeed) {
|
if (!enableAutoLongPressSpeed) {
|
||||||
_longPressSpeed.value = videoStorage
|
_longPressSpeed.value = videoStorage
|
||||||
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 3.0);
|
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 3.0);
|
||||||
@@ -980,8 +980,8 @@ class PlPlayerController {
|
|||||||
|
|
||||||
/// 设置后台播放
|
/// 设置后台播放
|
||||||
Future<void> setBackgroundPlay(bool val) async {
|
Future<void> setBackgroundPlay(bool val) async {
|
||||||
_backgroundPlay.value = val;
|
_continuePlayInBackground.value = val;
|
||||||
setting.put(SettingBoxKey.enableBackgroundPlay, val);
|
setting.put(SettingBoxKey.continuePlayInBackground, val);
|
||||||
videoPlayerServiceHandler.revalidateSetting();
|
videoPlayerServiceHandler.revalidateSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -496,10 +496,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Obx(
|
Obx(
|
||||||
() => Video(
|
() => Video(
|
||||||
key: ValueKey('${_.videoFit.value}${_.backgroundPlay.value}'),
|
key: ValueKey('${_.videoFit.value}${_.continuePlayInBackground.value}'),
|
||||||
controller: videoController,
|
controller: videoController,
|
||||||
controls: NoVideoControls,
|
controls: NoVideoControls,
|
||||||
pauseUponEnteringBackgroundMode: !_.backgroundPlay.value,
|
pauseUponEnteringBackgroundMode: !_.continuePlayInBackground.value,
|
||||||
resumeUponEnteringForegroundMode: true,
|
resumeUponEnteringForegroundMode: true,
|
||||||
subtitleViewConfiguration: const SubtitleViewConfiguration(
|
subtitleViewConfiguration: const SubtitleViewConfiguration(
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class SettingBoxKey {
|
|||||||
fullScreenGestureReverse = 'fullScreenGestureReverse',
|
fullScreenGestureReverse = 'fullScreenGestureReverse',
|
||||||
enableShowDanmaku = 'enableShowDanmaku',
|
enableShowDanmaku = 'enableShowDanmaku',
|
||||||
enableBackgroundPlay = 'enableBackgroundPlay',
|
enableBackgroundPlay = 'enableBackgroundPlay',
|
||||||
|
continuePlayInBackground = 'continuePlayInBackground',
|
||||||
|
|
||||||
/// 隐私
|
/// 隐私
|
||||||
blackMidsList = 'blackMidsList',
|
blackMidsList = 'blackMidsList',
|
||||||
|
|||||||
Reference in New Issue
Block a user