重构全屏逻辑,修复全屏弹幕与横屏错位问题
不再使用showDialog覆盖并传递对象的方式实现全屏,改用原控件调整高度(用Obx包裹SliverAppBar)、safeArea切换上下边距、构建detail页时根据屏幕方向切换状态栏可见性的方式实现全屏。 以上方式既能兼容屏幕旋转,也能绕过弹幕不加载的问题,还可以保留播放器上的弹幕避免旋屏时清空。 另外添加了两处针对全屏或旋屏状态的返回处理。
This commit is contained in:
@ -899,6 +899,7 @@ class PlPlayerController {
|
||||
await StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
||||
if (!isFullScreen.value && status) {
|
||||
/// 按照视频宽高比决定全屏方向
|
||||
toggleFullScreen(true);
|
||||
switch (mode) {
|
||||
case FullScreenMode.auto:
|
||||
if (direction.value == 'horizontal') {
|
||||
@ -927,41 +928,40 @@ class PlPlayerController {
|
||||
break;
|
||||
}
|
||||
|
||||
toggleFullScreen(true);
|
||||
bool isValid =
|
||||
direction.value == 'vertical' || mode == FullScreenMode.vertical
|
||||
? true
|
||||
: false;
|
||||
var result = await showDialog(
|
||||
context: Get.context!,
|
||||
useSafeArea: false,
|
||||
builder: (context) => Dialog.fullscreen(
|
||||
backgroundColor: Colors.black,
|
||||
child: SafeArea(
|
||||
// 忽略手机安全区域
|
||||
top: isValid,
|
||||
left: false,
|
||||
right: false,
|
||||
bottom: isValid,
|
||||
child: PLVideoPlayer(
|
||||
controller: this,
|
||||
headerControl: headerControl,
|
||||
bottomControl: bottomControl,
|
||||
danmuWidget: danmuWidget,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (result == null) {
|
||||
// 退出全屏
|
||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||
exitFullScreen();
|
||||
await verticalScreen();
|
||||
toggleFullScreen(false);
|
||||
}
|
||||
// bool isValid =
|
||||
// direction.value == 'vertical' || mode == FullScreenMode.vertical
|
||||
// ? true
|
||||
// : false;
|
||||
// var result = await showDialog(
|
||||
// context: Get.context!,
|
||||
// useSafeArea: false,
|
||||
// builder: (context) => Dialog.fullscreen(
|
||||
// backgroundColor: Colors.black,
|
||||
// child: SafeArea(
|
||||
// // 忽略手机安全区域
|
||||
// top: isValid,
|
||||
// left: false,
|
||||
// right: false,
|
||||
// bottom: isValid,
|
||||
// child: PLVideoPlayer(
|
||||
// controller: this,
|
||||
// headerControl: headerControl,
|
||||
// bottomControl: bottomControl,
|
||||
// danmuWidget: danmuWidget,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// if (result == null) {
|
||||
// // 退出全屏
|
||||
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||
// exitFullScreen();
|
||||
// await verticalScreen();
|
||||
// toggleFullScreen(false);
|
||||
// }
|
||||
} else if (isFullScreen.value) {
|
||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||
Get.back();
|
||||
// Get.back();
|
||||
exitFullScreen();
|
||||
await verticalScreen();
|
||||
toggleFullScreen(false);
|
||||
|
||||
Reference in New Issue
Block a user