mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-19 08:36:17 +08:00
@@ -1324,49 +1324,54 @@ class PlPlayerController {
|
||||
late final horizontalScreen = Pref.horizontalScreen;
|
||||
|
||||
// 全屏
|
||||
void triggerFullScreen({bool status = true, int duration = 500}) {
|
||||
EasyThrottle.throttle('fullScreen', Duration(milliseconds: duration),
|
||||
() async {
|
||||
stopScreenTimer();
|
||||
bool fsProcessing = false;
|
||||
Future<void> triggerFullScreen({bool status = true}) async {
|
||||
if (fsProcessing) {
|
||||
return;
|
||||
}
|
||||
fsProcessing = true;
|
||||
|
||||
if (!isFullScreen.value && status) {
|
||||
hideStatusBar();
|
||||
if (!isFullScreen.value && status) {
|
||||
hideStatusBar();
|
||||
|
||||
/// 按照视频宽高比决定全屏方向
|
||||
toggleFullScreen(true);
|
||||
/// 按照视频宽高比决定全屏方向
|
||||
toggleFullScreen(true);
|
||||
|
||||
/// 进入全屏
|
||||
if (mode == FullScreenMode.none) {
|
||||
return;
|
||||
}
|
||||
if (mode == FullScreenMode.gravity) {
|
||||
fullAutoModeForceSensor();
|
||||
return;
|
||||
}
|
||||
if (mode == FullScreenMode.vertical ||
|
||||
(mode == FullScreenMode.auto && direction.value == 'vertical') ||
|
||||
(mode == FullScreenMode.ratio &&
|
||||
(Get.height / Get.width < 1.25 ||
|
||||
direction.value == 'vertical'))) {
|
||||
await verticalScreenForTwoSeconds();
|
||||
} else {
|
||||
await landScape();
|
||||
}
|
||||
} else if (isFullScreen.value && !status) {
|
||||
if (Get.currentRoute.startsWith('/liveRoom') || !removeSafeArea) {
|
||||
showStatusBar();
|
||||
}
|
||||
toggleFullScreen(false);
|
||||
if (mode == FullScreenMode.none) {
|
||||
return;
|
||||
}
|
||||
if (!horizontalScreen) {
|
||||
await verticalScreenForTwoSeconds();
|
||||
} else {
|
||||
await autoScreen();
|
||||
}
|
||||
/// 进入全屏
|
||||
if (mode == FullScreenMode.none) {
|
||||
fsProcessing = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (mode == FullScreenMode.gravity) {
|
||||
fullAutoModeForceSensor();
|
||||
fsProcessing = false;
|
||||
return;
|
||||
}
|
||||
if (mode == FullScreenMode.vertical ||
|
||||
(mode == FullScreenMode.auto && direction.value == 'vertical') ||
|
||||
(mode == FullScreenMode.ratio &&
|
||||
(Get.height / Get.width < 1.25 ||
|
||||
direction.value == 'vertical'))) {
|
||||
await verticalScreenForTwoSeconds();
|
||||
} else {
|
||||
await landScape();
|
||||
}
|
||||
} else if (isFullScreen.value && !status) {
|
||||
if (Get.currentRoute.startsWith('/liveRoom') || !removeSafeArea) {
|
||||
showStatusBar();
|
||||
}
|
||||
toggleFullScreen(false);
|
||||
if (mode == FullScreenMode.none) {
|
||||
fsProcessing = false;
|
||||
return;
|
||||
}
|
||||
if (!horizontalScreen) {
|
||||
await verticalScreenForTwoSeconds();
|
||||
} else {
|
||||
await autoScreen();
|
||||
}
|
||||
}
|
||||
fsProcessing = false;
|
||||
}
|
||||
|
||||
void addPositionListener(Function(Duration position) listener) =>
|
||||
|
||||
@@ -7,12 +7,6 @@ import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
Timer? screenTimer;
|
||||
void stopScreenTimer() {
|
||||
screenTimer?.cancel();
|
||||
screenTimer = null;
|
||||
}
|
||||
|
||||
//横屏
|
||||
Future<void> landScape() async {
|
||||
dynamic document;
|
||||
@@ -40,10 +34,7 @@ Future<void> verticalScreenForTwoSeconds() async {
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
]);
|
||||
screenTimer = Timer(const Duration(seconds: 2), () {
|
||||
autoScreen();
|
||||
screenTimer = null;
|
||||
});
|
||||
await autoScreen();
|
||||
}
|
||||
|
||||
//竖屏
|
||||
@@ -54,8 +45,9 @@ Future<void> verticalScreen() async {
|
||||
}
|
||||
|
||||
//全向
|
||||
bool allowRotateScreen = Pref.allowRotateScreen;
|
||||
Future<void> autoScreen() async {
|
||||
if (!Pref.allowRotateScreen) {
|
||||
if (!allowRotateScreen) {
|
||||
return;
|
||||
}
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
|
||||
@@ -627,8 +627,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
size: 24,
|
||||
color: Colors.white,
|
||||
),
|
||||
onTap: () => plPlayerController.triggerFullScreen(
|
||||
status: !isFullScreen, duration: 800),
|
||||
onTap: () =>
|
||||
plPlayerController.triggerFullScreen(status: !isFullScreen),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -876,8 +876,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
||||
|
||||
void fullScreenTrigger(bool status) {
|
||||
plPlayerController.triggerFullScreen(
|
||||
status: status, duration: 800);
|
||||
plPlayerController.triggerFullScreen(status: status);
|
||||
}
|
||||
|
||||
if (cumulativeDy > threshold) {
|
||||
|
||||
Reference in New Issue
Block a user