diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 2143029a..5a86af82 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1173,6 +1173,10 @@ class PlPlayerController { if (mode == FullScreenMode.none) { return; } + if (mode == FullScreenMode.gravity) { + fullAutoModeForceSensor(); + return; + } if (mode == FullScreenMode.vertical || (mode == FullScreenMode.auto && direction.value == 'vertical') || (mode == FullScreenMode.ratio && diff --git a/lib/plugin/pl_player/models/fullscreen_mode.dart b/lib/plugin/pl_player/models/fullscreen_mode.dart index 46ded4ff..b7af5ce7 100644 --- a/lib/plugin/pl_player/models/fullscreen_mode.dart +++ b/lib/plugin/pl_player/models/fullscreen_mode.dart @@ -10,14 +10,23 @@ enum FullScreenMode { horizontal, // 屏幕长宽比<1.25或为竖屏视频时竖屏,否则横屏 ratio, + // 强制重力转屏(仅安卓) + gravity, } extension FullScreenModeDesc on FullScreenMode { - String get description => ['按视频方向(默认)', '不改变当前方向','强制竖屏', '强制横屏', '屏幕长宽比<1.25或为竖屏视频时竖屏,否则横屏'][index]; + String get description => [ + '按视频方向(默认)', + '不改变当前方向', + '强制竖屏', + '强制横屏', + '屏幕长宽比<1.25或为竖屏视频时竖屏,否则横屏', + '忽略系统方向锁定,强制按重力转屏(仅安卓)' + ][index]; } extension FullScreenModeCode on FullScreenMode { - static final List _codeList = [0, 1, 2, 3, 4]; + static final List _codeList = [0, 1, 2, 3, 4, 5]; int get code => _codeList[index]; static FullScreenMode? fromCode(int code) { diff --git a/lib/plugin/pl_player/utils/fullscreen.dart b/lib/plugin/pl_player/utils/fullscreen.dart index 1c33e414..ba95e2fb 100644 --- a/lib/plugin/pl_player/utils/fullscreen.dart +++ b/lib/plugin/pl_player/utils/fullscreen.dart @@ -58,6 +58,10 @@ Future autoScreen() async { ]); } +Future fullAutoModeForceSensor() async { + await AutoOrientation.fullAutoMode(forceSensor: true); +} + Future hideStatusBar() async { await SystemChrome.setEnabledSystemUIMode( SystemUiMode.immersiveSticky, diff --git a/pubspec.lock b/pubspec.lock index 4ddb768d..a162ab5a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -129,10 +129,11 @@ packages: auto_orientation: dependency: "direct main" description: - name: auto_orientation - sha256: cd56bb59b36fa54cc28ee254bc600524f022a4862f31d5ab20abd7bb1c54e678 - url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" - source: hosted + path: "." + ref: master + resolved-ref: "4d28c7d6dad6c099a44058527ddc65405a94b4d0" + url: "https://github.com/orz12/auto_orientation.git" + source: git version: "2.3.1" boolean_selector: dependency: transitive