mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
refactor device orientation
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -61,7 +61,6 @@ import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
@@ -162,7 +161,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
}
|
||||
|
||||
videoSourceInit();
|
||||
autoScreen();
|
||||
|
||||
addObserverMobile(this);
|
||||
}
|
||||
@@ -184,29 +182,14 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
late final ctr = videoDetailController.plPlayerController;
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
final isResume = state == .resumed;
|
||||
final ctr = videoDetailController.plPlayerController..visible = isResume;
|
||||
if (isResume) {
|
||||
if (!ctr.showDanmaku) {
|
||||
introController.startTimer();
|
||||
ctr.showDanmaku = true;
|
||||
|
||||
// 修复从后台恢复时全屏状态下屏幕方向错误的问题
|
||||
if (isFullScreen && Platform.isIOS) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// 根据视频方向重新设置屏幕方向
|
||||
final isVertical = videoDetailController.isVertical.value;
|
||||
final mode = ctr.mode;
|
||||
|
||||
if (!(mode == FullScreenMode.vertical ||
|
||||
(mode == FullScreenMode.auto && isVertical) ||
|
||||
(mode == FullScreenMode.ratio &&
|
||||
(isVertical || maxHeight / maxWidth < kScreenRatio)))) {
|
||||
landscape();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
} else if (state == .paused) {
|
||||
introController.cancelTimer();
|
||||
ctr.showDanmaku = false;
|
||||
}
|
||||
@@ -362,9 +345,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
pgcIntroController.cancelTimer();
|
||||
}
|
||||
}
|
||||
if (!videoDetailController.horizontalScreen) {
|
||||
AutoOrientation.portraitUpMode();
|
||||
}
|
||||
|
||||
if (!videoDetailController.plPlayerController.isCloseAll) {
|
||||
videoPlayerServiceHandler?.onVideoDetailDispose(heroTag);
|
||||
if (plPlayerController != null) {
|
||||
@@ -414,7 +395,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
|
||||
if (plPlayerController?.isCloseAll ?? false) {
|
||||
if (videoDetailController.plPlayerController.isCloseAll) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -472,6 +453,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
final size = MediaQuery.sizeOf(context);
|
||||
maxWidth = size.width;
|
||||
maxHeight = size.height;
|
||||
videoDetailController.plPlayerController.screenRatio = maxHeight / maxWidth;
|
||||
|
||||
final shortestSide = size.shortestSide;
|
||||
final minVideoHeight = shortestSide / Style.aspectRatio16x9;
|
||||
@@ -528,34 +510,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
videoDetailController.animationController
|
||||
..removeListener(animListener)
|
||||
..addListener(animListener);
|
||||
if (PlatformUtils.isMobile && mounted && isShowing && !isFullScreen) {
|
||||
if (isPortrait) {
|
||||
showStatusBar();
|
||||
} else if (!videoDetailController.horizontalScreen) {
|
||||
hideStatusBar();
|
||||
}
|
||||
}
|
||||
if (PlatformUtils.isMobile) {
|
||||
if (!isPortrait &&
|
||||
!isFullScreen &&
|
||||
plPlayerController != null &&
|
||||
videoDetailController.autoPlay) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
plPlayerController!.triggerFullScreen(
|
||||
status: true,
|
||||
isManualFS: false,
|
||||
mode: FullScreenMode.gravity,
|
||||
);
|
||||
});
|
||||
} else if (isPortrait &&
|
||||
isFullScreen &&
|
||||
plPlayerController?.isManualFS == false &&
|
||||
plPlayerController?.controlsLock.value == false) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
plPlayerController!.triggerFullScreen(status: false);
|
||||
});
|
||||
}
|
||||
}
|
||||
return Obx(
|
||||
() {
|
||||
final isFullScreen = this.isFullScreen;
|
||||
@@ -701,15 +655,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
.colorScheme
|
||||
.onSurface,
|
||||
),
|
||||
onPressed: () {
|
||||
videoDetailController
|
||||
.plPlayerController
|
||||
..isCloseAll = true
|
||||
..dispose();
|
||||
Get.until(
|
||||
(route) => route.isFirst,
|
||||
);
|
||||
},
|
||||
onPressed: videoDetailController
|
||||
.plPlayerController
|
||||
.onCloseAll,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1239,12 +1187,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
videoDetailController.plPlayerController
|
||||
..isCloseAll = true
|
||||
..dispose();
|
||||
Get.until((route) => route.isFirst);
|
||||
},
|
||||
onPressed:
|
||||
videoDetailController.plPlayerController.onCloseAll,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -2174,14 +2118,11 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
}
|
||||
|
||||
void _onPopInvokedWithResult(bool didPop, result) {
|
||||
if (plPlayerController?.onPopInvokedWithResult(didPop, result) ?? false) {
|
||||
return;
|
||||
}
|
||||
if (PlatformUtils.isMobile &&
|
||||
!videoDetailController.horizontalScreen &&
|
||||
!isPortrait) {
|
||||
verticalScreenForTwoSeconds();
|
||||
}
|
||||
videoDetailController.plPlayerController.onPopInvokedWithResult(
|
||||
didPop,
|
||||
result,
|
||||
isPortrait,
|
||||
);
|
||||
}
|
||||
|
||||
void onShowMemberPage(int? mid) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import 'package:PiliPlus/pages/video/widgets/header_mixin.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/services/shutdown_timer_service.dart'
|
||||
show shutdownTimerService;
|
||||
@@ -1757,21 +1756,11 @@ class HeaderControlState extends State<HeaderControl>
|
||||
size: 15,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
if (plPlayerController.onPopInvokedWithResult(
|
||||
false,
|
||||
null,
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
if (PlatformUtils.isMobile &&
|
||||
!horizontalScreen &&
|
||||
!isPortrait) {
|
||||
verticalScreenForTwoSeconds();
|
||||
} else {
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
onPressed: () => plPlayerController.onPopInvokedWithResult(
|
||||
false,
|
||||
null,
|
||||
videoDetailCtr.isPortrait,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!plPlayerController.isDesktopPip &&
|
||||
@@ -1787,12 +1776,7 @@ class HeaderControlState extends State<HeaderControl>
|
||||
size: 15,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
videoDetailCtr.plPlayerController
|
||||
..isCloseAll = true
|
||||
..dispose();
|
||||
Get.until((route) => route.isFirst);
|
||||
},
|
||||
onPressed: plPlayerController.onCloseAll,
|
||||
),
|
||||
),
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user