feat: 全屏新增强制按重力旋转

This commit is contained in:
orz12
2024-08-18 23:34:23 +08:00
parent 2ebf0a29b7
commit a49bbdab8c
4 changed files with 24 additions and 6 deletions

View File

@@ -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 &&

View File

@@ -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<int> _codeList = [0, 1, 2, 3, 4];
static final List<int> _codeList = [0, 1, 2, 3, 4, 5];
int get code => _codeList[index];
static FullScreenMode? fromCode(int code) {

View File

@@ -58,6 +58,10 @@ Future<void> autoScreen() async {
]);
}
Future<void> fullAutoModeForceSensor() async {
await AutoOrientation.fullAutoMode(forceSensor: true);
}
Future<void> hideStatusBar() async {
await SystemChrome.setEnabledSystemUIMode(
SystemUiMode.immersiveSticky,