mod: 竖屏改为只持续两秒

This commit is contained in:
orz12
2024-03-07 09:13:29 +08:00
parent ead21c8882
commit 9d684d1976
5 changed files with 29 additions and 18 deletions

View File

@@ -181,7 +181,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape) {
verticalScreen();
verticalScreenForTwoSeconds();
}
},
child: SizedBox(

View File

@@ -200,20 +200,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
plPlayerController!.isFullScreen.listen((bool status) {
if (status) {
videoDetailController.hiddenReplyReplyPanel();
hideStatusBar();
// hideStatusBar();
}
isFullScreen.value = status;
if (mounted) {
setState(() {});
}
if (!status) {
showStatusBar();
if (horizontalScreen) {
autoScreen();
} else {
verticalScreen();
}
}
// if (!status) {
// showStatusBar();
// if (horizontalScreen) {
// autoScreen();
// } else {
// verticalScreenForTwoSeconds();
// }
// }
});
}
@@ -371,7 +371,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreen();
verticalScreenForTwoSeconds();
}
},
child: Stack(
@@ -623,7 +623,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreen();
verticalScreenForTwoSeconds();
}
},
child: Stack(

View File

@@ -1052,7 +1052,7 @@ class _HeaderControlState extends State<HeaderControl> {
Orientation.landscape &&
!horizontalScreen)
{
verticalScreen(),
verticalScreenForTwoSeconds(),
},
Get.back()
}

View File

@@ -992,6 +992,8 @@ class PlPlayerController {
// 全屏
Future<void> triggerFullScreen({bool status = true}) async {
FullScreenMode mode = FullScreenModeCode.fromCode(
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
if (!isFullScreen.value && status) {
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
hideStatusBar();
@@ -1000,8 +1002,6 @@ class PlPlayerController {
toggleFullScreen(true);
/// 进入全屏
FullScreenMode mode = FullScreenModeCode.fromCode(
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
if (mode == FullScreenMode.none) {
return;
}
@@ -1010,7 +1010,7 @@ class PlPlayerController {
(mode == FullScreenMode.ratio &&
(Get.height / Get.width < 1.25 ||
direction.value == 'vertical'))) {
await verticalScreen();
await verticalScreenForTwoSeconds();
} else {
await landScape();
}
@@ -1018,8 +1018,9 @@ class PlPlayerController {
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
showStatusBar();
toggleFullScreen(false);
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
await verticalScreen();
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false) &&
mode != FullScreenMode.none) {
await verticalScreenForTwoSeconds();
}
}
}

View File

@@ -25,6 +25,16 @@ Future<void> landScape() async {
}
}
//竖屏
Future<void> verticalScreenForTwoSeconds() async {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
Future.delayed(const Duration(seconds: 2), () {
autoScreen();
});
}
//竖屏
Future<void> verticalScreen() async {
await SystemChrome.setPreferredOrientations([