Skip to content

Commit

Permalink
fix: 修复全屏异常,移除Obx中的全屏与退出相关逻辑,统一至监听器中
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Feb 23, 2024
1 parent 69d88fb commit ba5d990
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
55 changes: 31 additions & 24 deletions lib/pages/video/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
appbarStreamListen();
lifecycleListener();
fullScreenStatusListener();
autoScreen();
}

// 获取视频资源,初始化播放器
Expand Down Expand Up @@ -188,10 +189,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
plPlayerController?.isFullScreen.listen((bool isFullScreen) {
if (isFullScreen) {
videoDetailController.hiddenReplyReplyPanel();
enterFullScreen();
}
setState(() {
this.isFullScreen.value = isFullScreen;
});
if (!isFullScreen) {
exitFullScreen();
if (setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
autoScreen();
} else {
verticalScreen();
}
}
});
}

Expand Down Expand Up @@ -290,7 +300,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
}


@override
Widget build(BuildContext context) {
Widget childWhenDisabled = SafeArea(
Expand All @@ -317,13 +326,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
children: [
Obx(
() {
if (MediaQuery.of(context).orientation ==
Orientation.landscape ||
isFullScreen.value == true) {
enterFullScreen();
} else {
exitFullScreen();
}
final double videoheight = Get.width * 9 / 16;
final double videowidth = Get.width;
return SizedBox(
Expand Down Expand Up @@ -547,7 +549,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
},
),
Obx(
() => VideoReplyPanel(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
Expand Down Expand Up @@ -826,34 +828,39 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}
},
);
if (!horizontalScreen) {
if (Platform.isAndroid) {
return PiPSwitcher(
childWhenEnabled: childWhenEnabled,
childWhenDisabled: childWhenDisabled,
floating: floating,);
}
return childWhenDisabled;
}
// if (!horizontalScreen) {
// if (Platform.isAndroid) {
// return PiPSwitcher(
// childWhenEnabled: childWhenEnabled,
// childWhenDisabled: childWhenDisabled,
// floating: floating,);
// }
// return childWhenDisabled;
// }
return OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
print("orientation $orientation");
if (orientation == Orientation.landscape) {
enterFullScreen();
if (!horizontalScreen) {
videoDetailController.hiddenReplyReplyPanel();
}
} else if (!isFullScreen.value) {
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
}
if (Platform.isAndroid) {
return PiPSwitcher(
childWhenDisabled: orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape,
childWhenDisabled:
!horizontalScreen || orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape,
childWhenEnabled: childWhenEnabled,
floating: floating,
);
}
return orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape;
return !horizontalScreen || orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape;
});
}
}
5 changes: 0 additions & 5 deletions lib/plugin/pl_player/utils/fullscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ Future<void> exitFullScreen() async {
mode,
overlays: SystemUiOverlay.values,
);
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 ba5d990

Please sign in to comment.