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 defaultAudioQa;
|
||||||
late dynamic defaultDecode;
|
late dynamic defaultDecode;
|
||||||
late int defaultFullScreenMode;
|
late int defaultFullScreenMode;
|
||||||
|
late bool lockLandscape;
|
||||||
late int defaultBtmProgressBehavior;
|
late int defaultBtmProgressBehavior;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -39,6 +40,8 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||||
defaultValue: FullScreenMode.values.first.code);
|
defaultValue: FullScreenMode.values.first.code);
|
||||||
|
lockLandscape = setting.get(SettingBoxKey.lockLandscape,
|
||||||
|
defaultValue: false);
|
||||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||||
defaultValue: BtmProgresBehavior.values.first.code);
|
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(
|
const SetSwitchItem(
|
||||||
title: '开启硬解',
|
title: '开启硬解',
|
||||||
subTitle: '以较低功耗播放视频',
|
subTitle: '以较低功耗播放视频',
|
||||||
|
|||||||
@@ -247,10 +247,6 @@ class VideoDetailController extends GetxController
|
|||||||
plPlayerController.headerControl = headerControl;
|
plPlayerController.headerControl = headerControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTriggerFullScreenCallback(void Function({bool? status}) callback) {
|
|
||||||
plPlayerController.setTriggerFullscreenCallback(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 视频链接
|
// 视频链接
|
||||||
Future queryVideoUrl() async {
|
Future queryVideoUrl() async {
|
||||||
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
|
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
autoPlayEnable =
|
autoPlayEnable =
|
||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||||
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
||||||
videoDetailController
|
|
||||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
|
||||||
videoSourceInit();
|
videoSourceInit();
|
||||||
appbarStreamListen();
|
appbarStreamListen();
|
||||||
lifecycleListener();
|
lifecycleListener();
|
||||||
@@ -158,8 +156,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
/// 未开启自动播放时触发播放
|
/// 未开启自动播放时触发播放
|
||||||
Future<void> handlePlay() async {
|
Future<void> handlePlay() async {
|
||||||
videoDetailController
|
|
||||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
|
||||||
await videoDetailController.playerInit();
|
await videoDetailController.playerInit();
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
plPlayerController!.addStatusLister(playerListener);
|
plPlayerController!.addStatusLister(playerListener);
|
||||||
@@ -193,6 +189,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
videoDetailController.hiddenReplyReplyPanel();
|
videoDetailController.hiddenReplyReplyPanel();
|
||||||
}
|
}
|
||||||
|
setState(() {
|
||||||
|
this.isFullScreen.value = isFullScreen;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,8 +243,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
}
|
}
|
||||||
videoDetailController.isFirstTime = false;
|
videoDetailController.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
videoDetailController
|
|
||||||
.setTriggerFullScreenCallback(triggerFullScreenCallback);
|
|
||||||
videoDetailController.playerInit(autoplay: autoplay);
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ Box localCache = GStrorage.localCache;
|
|||||||
class PlPlayerController {
|
class PlPlayerController {
|
||||||
Player? _videoPlayerController;
|
Player? _videoPlayerController;
|
||||||
VideoController? _videoController;
|
VideoController? _videoController;
|
||||||
void Function({bool? status})? triggerFullscreenCallback;
|
|
||||||
|
|
||||||
// 添加一个私有静态变量来保存实例
|
// 添加一个私有静态变量来保存实例
|
||||||
static PlPlayerController? _instance;
|
static PlPlayerController? _instance;
|
||||||
@@ -233,11 +232,6 @@ class PlPlayerController {
|
|||||||
// 播放顺序相关
|
// 播放顺序相关
|
||||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||||
|
|
||||||
void setTriggerFullscreenCallback(
|
|
||||||
void Function({bool? status}) triggerFullscreenCallback) {
|
|
||||||
this.triggerFullscreenCallback = triggerFullscreenCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateSliderPositionSecond() {
|
void updateSliderPositionSecond() {
|
||||||
int newSecond = _sliderPosition.value.inSeconds;
|
int newSecond = _sliderPosition.value.inSeconds;
|
||||||
if (sliderPositionSeconds.value != newSecond) {
|
if (sliderPositionSeconds.value != newSecond) {
|
||||||
@@ -967,9 +961,6 @@ class PlPlayerController {
|
|||||||
await landScape();
|
await landScape();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (triggerFullscreenCallback != null) {
|
|
||||||
triggerFullscreenCallback!(status: status);
|
|
||||||
}
|
|
||||||
} else if (isFullScreen.value && !status) {
|
} else if (isFullScreen.value && !status) {
|
||||||
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
||||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||||
@@ -978,9 +969,6 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
exitFullScreen();
|
exitFullScreen();
|
||||||
toggleFullScreen(false);
|
toggleFullScreen(false);
|
||||||
if (triggerFullscreenCallback != null) {
|
|
||||||
triggerFullscreenCallback!(status: status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,16 +15,14 @@ Future<void> landScape() async {
|
|||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
await document.documentElement?.requestFullscreen();
|
await document.documentElement?.requestFullscreen();
|
||||||
} else if (Platform.isAndroid || Platform.isIOS) {
|
} else if (Platform.isAndroid || Platform.isIOS) {
|
||||||
// await SystemChrome.setEnabledSystemUIMode(
|
if (setting.get(SettingBoxKey.lockLandscape, defaultValue: false)) {
|
||||||
// SystemUiMode.immersiveSticky,
|
await SystemChrome.setPreferredOrientations(
|
||||||
// overlays: [],
|
[
|
||||||
// );
|
DeviceOrientation.landscapeLeft,
|
||||||
// await SystemChrome.setPreferredOrientations(
|
DeviceOrientation.landscapeRight,
|
||||||
// [
|
],
|
||||||
// DeviceOrientation.landscapeLeft,
|
);
|
||||||
// DeviceOrientation.landscapeRight,
|
}
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
||||||
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
||||||
await const MethodChannel('com.alexmercerind/media_kit_video')
|
await const MethodChannel('com.alexmercerind/media_kit_video')
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class SettingBoxKey {
|
|||||||
defaultAudioQa = 'defaultAudioQa',
|
defaultAudioQa = 'defaultAudioQa',
|
||||||
autoPlayEnable = 'autoPlayEnable',
|
autoPlayEnable = 'autoPlayEnable',
|
||||||
fullScreenMode = 'fullScreenMode',
|
fullScreenMode = 'fullScreenMode',
|
||||||
|
lockLandscape = 'lockLandscape',
|
||||||
defaultDecode = 'defaultDecode',
|
defaultDecode = 'defaultDecode',
|
||||||
danmakuEnable = 'danmakuEnable',
|
danmakuEnable = 'danmakuEnable',
|
||||||
defaultToastOp = 'defaultToastOp',
|
defaultToastOp = 'defaultToastOp',
|
||||||
|
|||||||
Reference in New Issue
Block a user