From 372c677e8f01f49745514d6f411fa87a6659f204 Mon Sep 17 00:00:00 2001 From: dom Date: Tue, 14 Apr 2026 13:13:07 +0800 Subject: [PATCH] opt android orientation Signed-off-by: dom --- lib/plugin/pl_player/controller.dart | 17 ++++++++++++----- pubspec.lock | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index f9894e007..c98d9c154 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -531,7 +531,10 @@ class PlPlayerController with BlockConfigMixin { final isFullScreen = this.isFullScreen.value; if (checkIsAutoRotate && param.isAutoRotate != true && - (!isFullScreen || _isVertical || orientation == .portraitUp)) { + (!isFullScreen || + _isVertical || + orientation == .portraitUp || + orientation == .portraitDown)) { return; } switch (orientation) { @@ -544,6 +547,10 @@ class PlPlayerController with BlockConfigMixin { } else { portraitUpMode(); } + case .portraitDown: + if (!horizontalScreen) return; + if (!_isVertical && controlsLock.value) return; + portraitDownMode(); case .landscapeLeft: if (!horizontalScreen && !isFullScreen) { triggerFullScreen(orientation: orientation, isManualFS: false); @@ -556,13 +563,12 @@ class PlPlayerController with BlockConfigMixin { } else { landscapeRightMode(); } - case _: } } // 添加一个私有构造函数 PlPlayerController._() { - if (PlatformUtils.isMobile && !horizontalScreen) { + if (PlatformUtils.isMobile) { _orientationListener = NativeDeviceOrientationPlatform.instance .onOrientationChanged( useSensor: Platform.isAndroid, @@ -1438,7 +1444,6 @@ class PlPlayerController with BlockConfigMixin { if (status) { if (PlatformUtils.isMobile) { hideStatusBar(); - if (horizontalScreen) return; if (orientation == null && mode == .none) { return; } @@ -1584,7 +1589,9 @@ class PlPlayerController with BlockConfigMixin { bool get isCloseAll => _isCloseAll; void resetScreenRotation() { - if (!horizontalScreen) { + if (horizontalScreen) { + fullMode(); + } else { portraitUpMode(); } } diff --git a/pubspec.lock b/pubspec.lock index 606f6af9f..7de2cc911 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1251,7 +1251,7 @@ packages: description: path: "." ref: master - resolved-ref: "64cbc7886f5a5a5ecb09a34aab0d8b9ee48d03d2" + resolved-ref: "240534adb4b4b5c2c7e6c4578b1fc052ce98d7fd" url: "https://github.com/bggRGjQaUbCoE/flutter_native_device_orientation.git" source: git version: "2.0.5"