mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 改善全屏体验,增加额外横屏设置,替换全屏实现方法
This commit is contained in:
@@ -26,6 +26,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
late dynamic defaultAudioQa;
|
||||
late dynamic defaultDecode;
|
||||
late int defaultFullScreenMode;
|
||||
late bool lockLandscape;
|
||||
late int defaultBtmProgressBehavior;
|
||||
|
||||
@override
|
||||
@@ -39,6 +40,8 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
defaultValue: VideoDecodeFormats.values.last.code);
|
||||
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||
defaultValue: FullScreenMode.values.first.code);
|
||||
lockLandscape = setting.get(SettingBoxKey.lockLandscape,
|
||||
defaultValue: false);
|
||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||
defaultValue: BtmProgresBehavior.values.first.code);
|
||||
}
|
||||
@@ -133,6 +136,12 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
}
|
||||
}
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '额外横屏',
|
||||
subTitle: '执行播放器横屏前,额外施加屏幕旋转方向限制',
|
||||
setKey: SettingBoxKey.lockLandscape,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '开启硬解',
|
||||
subTitle: '以较低功耗播放视频',
|
||||
|
||||
@@ -247,10 +247,6 @@ class VideoDetailController extends GetxController
|
||||
plPlayerController.headerControl = headerControl;
|
||||
}
|
||||
|
||||
void setTriggerFullScreenCallback(void Function({bool? status}) callback) {
|
||||
plPlayerController.setTriggerFullscreenCallback(callback);
|
||||
}
|
||||
|
||||
// 视频链接
|
||||
Future queryVideoUrl() async {
|
||||
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
|
||||
|
||||
@@ -92,8 +92,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
autoPlayEnable =
|
||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
||||
videoDetailController
|
||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
||||
videoSourceInit();
|
||||
appbarStreamListen();
|
||||
lifecycleListener();
|
||||
@@ -158,8 +156,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
/// 未开启自动播放时触发播放
|
||||
Future<void> handlePlay() async {
|
||||
videoDetailController
|
||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
||||
await videoDetailController.playerInit();
|
||||
plPlayerController = videoDetailController.plPlayerController;
|
||||
plPlayerController!.addStatusLister(playerListener);
|
||||
@@ -193,6 +189,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
if (isFullScreen) {
|
||||
videoDetailController.hiddenReplyReplyPanel();
|
||||
}
|
||||
setState(() {
|
||||
this.isFullScreen.value = isFullScreen;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -244,8 +243,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
videoDetailController.isFirstTime = false;
|
||||
final bool autoplay = autoPlayEnable;
|
||||
videoDetailController
|
||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
||||
videoDetailController.playerInit(autoplay: autoplay);
|
||||
|
||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||
@@ -293,12 +290,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
}
|
||||
|
||||
void triggerFullScreenCallback({bool? status}) {
|
||||
// SmartDialog.showToast('triggerFullScreen $status $isFullScreen.value');
|
||||
setState(() {
|
||||
isFullScreen.value = status ?? !isFullScreen.value;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -31,7 +31,6 @@ Box localCache = GStrorage.localCache;
|
||||
class PlPlayerController {
|
||||
Player? _videoPlayerController;
|
||||
VideoController? _videoController;
|
||||
void Function({bool? status})? triggerFullscreenCallback;
|
||||
|
||||
// 添加一个私有静态变量来保存实例
|
||||
static PlPlayerController? _instance;
|
||||
@@ -233,11 +232,6 @@ class PlPlayerController {
|
||||
// 播放顺序相关
|
||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||
|
||||
void setTriggerFullscreenCallback(
|
||||
void Function({bool? status}) triggerFullscreenCallback) {
|
||||
this.triggerFullscreenCallback = triggerFullscreenCallback;
|
||||
}
|
||||
|
||||
void updateSliderPositionSecond() {
|
||||
int newSecond = _sliderPosition.value.inSeconds;
|
||||
if (sliderPositionSeconds.value != newSecond) {
|
||||
@@ -967,9 +961,6 @@ class PlPlayerController {
|
||||
await landScape();
|
||||
}
|
||||
|
||||
if (triggerFullscreenCallback != null) {
|
||||
triggerFullscreenCallback!(status: status);
|
||||
}
|
||||
} else if (isFullScreen.value && !status) {
|
||||
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||
@@ -978,9 +969,6 @@ class PlPlayerController {
|
||||
}
|
||||
exitFullScreen();
|
||||
toggleFullScreen(false);
|
||||
if (triggerFullscreenCallback != null) {
|
||||
triggerFullscreenCallback!(status: status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,16 +15,14 @@ Future<void> landScape() async {
|
||||
if (kIsWeb) {
|
||||
await document.documentElement?.requestFullscreen();
|
||||
} else if (Platform.isAndroid || Platform.isIOS) {
|
||||
// await SystemChrome.setEnabledSystemUIMode(
|
||||
// SystemUiMode.immersiveSticky,
|
||||
// overlays: [],
|
||||
// );
|
||||
// await SystemChrome.setPreferredOrientations(
|
||||
// [
|
||||
// DeviceOrientation.landscapeLeft,
|
||||
// DeviceOrientation.landscapeRight,
|
||||
// ],
|
||||
// );
|
||||
if (setting.get(SettingBoxKey.lockLandscape, defaultValue: false)) {
|
||||
await SystemChrome.setPreferredOrientations(
|
||||
[
|
||||
DeviceOrientation.landscapeLeft,
|
||||
DeviceOrientation.landscapeRight,
|
||||
],
|
||||
);
|
||||
}
|
||||
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
||||
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
||||
await const MethodChannel('com.alexmercerind/media_kit_video')
|
||||
|
||||
@@ -80,6 +80,7 @@ class SettingBoxKey {
|
||||
defaultAudioQa = 'defaultAudioQa',
|
||||
autoPlayEnable = 'autoPlayEnable',
|
||||
fullScreenMode = 'fullScreenMode',
|
||||
lockLandscape = 'lockLandscape',
|
||||
defaultDecode = 'defaultDecode',
|
||||
danmakuEnable = 'danmakuEnable',
|
||||
defaultToastOp = 'defaultToastOp',
|
||||
|
||||
Reference in New Issue
Block a user