mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-18 16:16:14 +08:00
@@ -7,6 +7,8 @@ import 'package:PiliPlus/pages/setting/models/model.dart';
|
|||||||
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
||||||
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
|
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
|
||||||
|
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart'
|
||||||
|
show allowRotateScreen;
|
||||||
import 'package:PiliPlus/services/service_locator.dart';
|
import 'package:PiliPlus/services/service_locator.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
@@ -152,6 +154,7 @@ List<SettingsModel> get playSettings => [
|
|||||||
leading: const Icon(Icons.screen_rotation_alt_outlined),
|
leading: const Icon(Icons.screen_rotation_alt_outlined),
|
||||||
setKey: SettingBoxKey.allowRotateScreen,
|
setKey: SettingBoxKey.allowRotateScreen,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
|
onChanged: (value) => allowRotateScreen = value,
|
||||||
),
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
|
|||||||
@@ -1324,49 +1324,54 @@ class PlPlayerController {
|
|||||||
late final horizontalScreen = Pref.horizontalScreen;
|
late final horizontalScreen = Pref.horizontalScreen;
|
||||||
|
|
||||||
// 全屏
|
// 全屏
|
||||||
void triggerFullScreen({bool status = true, int duration = 500}) {
|
bool fsProcessing = false;
|
||||||
EasyThrottle.throttle('fullScreen', Duration(milliseconds: duration),
|
Future<void> triggerFullScreen({bool status = true}) async {
|
||||||
() async {
|
if (fsProcessing) {
|
||||||
stopScreenTimer();
|
return;
|
||||||
|
}
|
||||||
|
fsProcessing = true;
|
||||||
|
|
||||||
if (!isFullScreen.value && status) {
|
if (!isFullScreen.value && status) {
|
||||||
hideStatusBar();
|
hideStatusBar();
|
||||||
|
|
||||||
/// 按照视频宽高比决定全屏方向
|
/// 按照视频宽高比决定全屏方向
|
||||||
toggleFullScreen(true);
|
toggleFullScreen(true);
|
||||||
|
|
||||||
/// 进入全屏
|
/// 进入全屏
|
||||||
if (mode == FullScreenMode.none) {
|
if (mode == FullScreenMode.none) {
|
||||||
return;
|
fsProcessing = false;
|
||||||
}
|
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.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) =>
|
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/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
Timer? screenTimer;
|
|
||||||
void stopScreenTimer() {
|
|
||||||
screenTimer?.cancel();
|
|
||||||
screenTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//横屏
|
//横屏
|
||||||
Future<void> landScape() async {
|
Future<void> landScape() async {
|
||||||
dynamic document;
|
dynamic document;
|
||||||
@@ -40,10 +34,7 @@ Future<void> verticalScreenForTwoSeconds() async {
|
|||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
]);
|
]);
|
||||||
screenTimer = Timer(const Duration(seconds: 2), () {
|
await autoScreen();
|
||||||
autoScreen();
|
|
||||||
screenTimer = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//竖屏
|
//竖屏
|
||||||
@@ -54,8 +45,9 @@ Future<void> verticalScreen() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//全向
|
//全向
|
||||||
|
bool allowRotateScreen = Pref.allowRotateScreen;
|
||||||
Future<void> autoScreen() async {
|
Future<void> autoScreen() async {
|
||||||
if (!Pref.allowRotateScreen) {
|
if (!allowRotateScreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
|
|||||||
@@ -627,8 +627,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
size: 24,
|
size: 24,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
onTap: () => plPlayerController.triggerFullScreen(
|
onTap: () =>
|
||||||
status: !isFullScreen, duration: 800),
|
plPlayerController.triggerFullScreen(status: !isFullScreen),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -876,8 +876,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
details.localFocalPoint.dy - _initialFocalPoint.dy;
|
||||||
|
|
||||||
void fullScreenTrigger(bool status) {
|
void fullScreenTrigger(bool status) {
|
||||||
plPlayerController.triggerFullScreen(
|
plPlayerController.triggerFullScreen(status: status);
|
||||||
status: status, duration: 800);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cumulativeDy > threshold) {
|
if (cumulativeDy > threshold) {
|
||||||
|
|||||||
Reference in New Issue
Block a user