mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
opt fullscreen
Closes #1442 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -369,7 +369,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
}
|
}
|
||||||
PageUtils.routeObserver.unsubscribe(this);
|
PageUtils.routeObserver.unsubscribe(this);
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
if (Utils.isMobile) {
|
||||||
showStatusBar();
|
showStatusBar();
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,7 +547,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
videoDetailController.animationController
|
videoDetailController.animationController
|
||||||
..removeListener(animListener)
|
..removeListener(animListener)
|
||||||
..addListener(animListener);
|
..addListener(animListener);
|
||||||
if (mounted && isShowing && !isFullScreen) {
|
if (Utils.isMobile && mounted && isShowing && !isFullScreen) {
|
||||||
if (isPortrait) {
|
if (isPortrait) {
|
||||||
if (!videoDetailController.imageStatus) {
|
if (!videoDetailController.imageStatus) {
|
||||||
showStatusBar();
|
showStatusBar();
|
||||||
|
|||||||
@@ -1511,40 +1511,42 @@ class PlPlayerController {
|
|||||||
bool status = true,
|
bool status = true,
|
||||||
bool inAppFullScreen = false,
|
bool inAppFullScreen = false,
|
||||||
}) async {
|
}) async {
|
||||||
|
if (isFullScreen.value == status) return;
|
||||||
|
|
||||||
if (fsProcessing) {
|
if (fsProcessing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fsProcessing = true;
|
fsProcessing = true;
|
||||||
|
|
||||||
if (!isFullScreen.value && status) {
|
toggleFullScreen(status);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
if (Utils.isMobile) {
|
||||||
hideStatusBar();
|
hideStatusBar();
|
||||||
|
|
||||||
/// 按照视频宽高比决定全屏方向
|
|
||||||
toggleFullScreen(true);
|
|
||||||
|
|
||||||
/// 进入全屏
|
|
||||||
if (mode == FullScreenMode.none) {
|
if (mode == FullScreenMode.none) {
|
||||||
fsProcessing = false;
|
fsProcessing = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode == FullScreenMode.gravity) {
|
if (mode == FullScreenMode.gravity) {
|
||||||
fullAutoModeForceSensor();
|
await fullAutoModeForceSensor();
|
||||||
fsProcessing = false;
|
fsProcessing = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
late final size = Get.size;
|
late final size = Get.mediaQuery.size;
|
||||||
if (Utils.isMobile &&
|
if ((mode == FullScreenMode.vertical ||
|
||||||
(mode == FullScreenMode.vertical ||
|
|
||||||
(mode == FullScreenMode.auto && isVertical) ||
|
(mode == FullScreenMode.auto && isVertical) ||
|
||||||
(mode == FullScreenMode.ratio &&
|
(mode == FullScreenMode.ratio &&
|
||||||
(isVertical || size.height / size.width < 1.25)))) {
|
(isVertical || size.height / size.width < 1.25)))) {
|
||||||
await verticalScreenForTwoSeconds();
|
await verticalScreenForTwoSeconds();
|
||||||
} else {
|
} else {
|
||||||
await landscape(inAppFullScreen: inAppFullScreen);
|
await landscape();
|
||||||
}
|
}
|
||||||
} else if (isFullScreen.value && !status) {
|
} else {
|
||||||
|
await enterDesktopFullscreen();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Utils.isMobile) {
|
||||||
showStatusBar();
|
showStatusBar();
|
||||||
toggleFullScreen(false);
|
|
||||||
if (mode == FullScreenMode.none) {
|
if (mode == FullScreenMode.none) {
|
||||||
fsProcessing = false;
|
fsProcessing = false;
|
||||||
return;
|
return;
|
||||||
@@ -1554,6 +1556,9 @@ class PlPlayerController {
|
|||||||
} else {
|
} else {
|
||||||
await autoScreen();
|
await autoScreen();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await exitDesktopFullscreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fsProcessing = false;
|
fsProcessing = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,45 +7,53 @@ import 'package:auto_orientation/auto_orientation.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
//横屏
|
bool _isDesktopFullScreen = false;
|
||||||
Future<void> landscape({bool inAppFullScreen = false}) async {
|
|
||||||
|
Future<void> enterDesktopFullscreen({bool inAppFullScreen = false}) async {
|
||||||
|
if (!inAppFullScreen && !_isDesktopFullScreen) {
|
||||||
|
_isDesktopFullScreen = true;
|
||||||
try {
|
try {
|
||||||
if (Utils.isMobile) {
|
|
||||||
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
|
||||||
} else if (Utils.isDesktop && !inAppFullScreen) {
|
|
||||||
await const MethodChannel(
|
await const MethodChannel(
|
||||||
'com.alexmercerind/media_kit_video',
|
'com.alexmercerind/media_kit_video',
|
||||||
).invokeMethod('Utils.EnterNativeFullscreen');
|
).invokeMethod('Utils.EnterNativeFullscreen');
|
||||||
|
} catch (_) {
|
||||||
|
if (kDebugMode) rethrow;
|
||||||
}
|
}
|
||||||
} catch (exception, stacktrace) {
|
|
||||||
if (kDebugMode) {
|
|
||||||
debugPrint(exception.toString());
|
|
||||||
debugPrint(stacktrace.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> exitDesktopFullscreen() async {
|
||||||
|
if (_isDesktopFullScreen) {
|
||||||
|
_isDesktopFullScreen = false;
|
||||||
|
try {
|
||||||
|
await const MethodChannel(
|
||||||
|
'com.alexmercerind/media_kit_video',
|
||||||
|
).invokeMethod('Utils.ExitNativeFullscreen');
|
||||||
|
} catch (_) {
|
||||||
|
if (kDebugMode) rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//横屏
|
||||||
|
Future<void> landscape() async {
|
||||||
|
try {
|
||||||
|
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
||||||
|
} catch (_) {
|
||||||
|
if (kDebugMode) rethrow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//竖屏
|
//竖屏
|
||||||
Future<void> verticalScreenForTwoSeconds() async {
|
Future<void> verticalScreenForTwoSeconds() async {
|
||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
]);
|
|
||||||
await autoScreen();
|
await autoScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
//竖屏
|
|
||||||
Future<void> verticalScreen() async {
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//全向
|
//全向
|
||||||
bool allowRotateScreen = Pref.allowRotateScreen;
|
bool allowRotateScreen = Pref.allowRotateScreen;
|
||||||
Future<void> autoScreen() async {
|
Future<void> autoScreen() async {
|
||||||
if (!allowRotateScreen) {
|
if (Utils.isMobile && allowRotateScreen) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
// DeviceOrientation.portraitDown,
|
// DeviceOrientation.portraitDown,
|
||||||
@@ -53,31 +61,27 @@ Future<void> autoScreen() async {
|
|||||||
DeviceOrientation.landscapeRight,
|
DeviceOrientation.landscapeRight,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> fullAutoModeForceSensor() async {
|
Future<void> fullAutoModeForceSensor() async {
|
||||||
await AutoOrientation.fullAutoMode(forceSensor: true);
|
await AutoOrientation.fullAutoMode(forceSensor: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _showStatusBar = true;
|
||||||
Future<void> hideStatusBar() async {
|
Future<void> hideStatusBar() async {
|
||||||
if (!_showStatusBar) {
|
if (!_showStatusBar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_showStatusBar = false;
|
_showStatusBar = false;
|
||||||
await SystemChrome.setEnabledSystemUIMode(
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
||||||
SystemUiMode.immersiveSticky,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _showStatusBar = true;
|
|
||||||
|
|
||||||
//退出全屏显示
|
//退出全屏显示
|
||||||
Future<void> showStatusBar() async {
|
Future<void> showStatusBar() async {
|
||||||
if (_showStatusBar) {
|
if (_showStatusBar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_showStatusBar = true;
|
_showStatusBar = true;
|
||||||
try {
|
|
||||||
if (Utils.isMobile) {
|
|
||||||
SystemUiMode mode;
|
SystemUiMode mode;
|
||||||
if (Platform.isAndroid && (await Utils.sdkInt < 29)) {
|
if (Platform.isAndroid && (await Utils.sdkInt < 29)) {
|
||||||
mode = SystemUiMode.manual;
|
mode = SystemUiMode.manual;
|
||||||
@@ -88,12 +92,4 @@ Future<void> showStatusBar() async {
|
|||||||
mode,
|
mode,
|
||||||
overlays: SystemUiOverlay.values,
|
overlays: SystemUiOverlay.values,
|
||||||
);
|
);
|
||||||
} else if (Utils.isDesktop) {
|
|
||||||
await const MethodChannel(
|
|
||||||
'com.alexmercerind/media_kit_video',
|
|
||||||
).invokeMethod('Utils.ExitNativeFullscreen');
|
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
if (kDebugMode) rethrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user