Skip to content

Commit

Permalink
fix: 退出全屏逻辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Feb 22, 2024
1 parent 43e0e4a commit 87c2ffe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions lib/pages/video/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'package:PiliPalaX/plugin/pl_player/index.dart';
import 'package:PiliPalaX/plugin/pl_player/models/play_repeat.dart';
import 'package:PiliPalaX/services/service_locator.dart';
import 'package:PiliPalaX/utils/storage.dart';
import 'package:status_bar_control/status_bar_control.dart';

import '../../../services/shutdown_timer_service.dart';
import 'widgets/header_control.dart';
Expand Down Expand Up @@ -202,6 +203,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoPlayerServiceHandler.onVideoDetailDispose();
floating.dispose();
_lifecycleListener.dispose();
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
exitFullScreen();
super.dispose();
}
Expand Down Expand Up @@ -838,6 +840,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
builder: (BuildContext context, Orientation orientation) {
if (orientation == Orientation.landscape) {
enterFullScreen();
} else if (!isFullScreen.value) {
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
}
if (Platform.isAndroid) {
return PiPSwitcher(
Expand Down
14 changes: 7 additions & 7 deletions lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,15 @@ class PlPlayerController {

// 全屏
Future<void> triggerFullScreen({bool status = true}) async {
FullScreenMode mode = FullScreenModeCode.fromCode(
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
await StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
if (!isFullScreen.value && status) {
await StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
/// 按照视频宽高比决定全屏方向
toggleFullScreen(true);

/// 进入全屏
await enterFullScreen();
FullScreenMode mode = FullScreenModeCode.fromCode(
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
if (mode == FullScreenMode.vertical ||
(mode == FullScreenMode.auto && direction.value == 'vertical') ||
(mode == FullScreenMode.ratio &&
Expand Down Expand Up @@ -999,12 +999,12 @@ class PlPlayerController {
// toggleFullScreen(false);
// }
} else if (isFullScreen.value) {
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
// Get.back();
exitFullScreen();
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
await verticalScreen();
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
// Get.back();
// await verticalScreen();
}
exitFullScreen();
toggleFullScreen(false);
}
if (triggerFullscreenCallback != null) {
Expand Down
9 changes: 8 additions & 1 deletion lib/plugin/pl_player/utils/fullscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import 'package:auto_orientation/auto_orientation.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import '../../../common/widgets/custom_toast.dart';
import '../../../utils/storage.dart';

//横屏
Future<void> landScape() async {
dynamic document;
Expand Down Expand Up @@ -74,7 +77,11 @@ Future<void> exitFullScreen() async {
mode,
overlays: SystemUiOverlay.values,
);
await SystemChrome.setPreferredOrientations([]);
if (setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
autoScreen();
} else {
verticalScreen();
}
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
await const MethodChannel('com.alexmercerind/media_kit_video')
.invokeMethod(
Expand Down

0 comments on commit 87c2ffe

Please sign in to comment.