feat: 全屏方式设置
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/video/play/quality.dart';
|
import 'package:pilipala/models/video/play/quality.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
import 'widgets/switch_item.dart';
|
import 'widgets/switch_item.dart';
|
||||||
@ -17,6 +18,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
late dynamic defaultVideoQa;
|
late dynamic defaultVideoQa;
|
||||||
late dynamic defaultAudioQa;
|
late dynamic defaultAudioQa;
|
||||||
late dynamic defaultDecode;
|
late dynamic defaultDecode;
|
||||||
|
late int defaultFullScreenMode;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -27,6 +29,8 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
defaultValue: AudioQuality.values.last.code);
|
defaultValue: AudioQuality.values.last.code);
|
||||||
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
|
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||||
|
defaultValue: FullScreenMode.values.first.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -68,7 +72,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
),
|
),
|
||||||
trailing: PopupMenuButton(
|
trailing: PopupMenuButton(
|
||||||
initialValue: defaultVideoQa,
|
initialValue: defaultVideoQa,
|
||||||
icon: const Icon(Icons.arrow_forward_rounded, size: 22),
|
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||||
onSelected: (item) {
|
onSelected: (item) {
|
||||||
defaultVideoQa = item;
|
defaultVideoQa = item;
|
||||||
setting.put(SettingBoxKey.defaultVideoQa, item);
|
setting.put(SettingBoxKey.defaultVideoQa, item);
|
||||||
@ -93,7 +97,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
),
|
),
|
||||||
trailing: PopupMenuButton(
|
trailing: PopupMenuButton(
|
||||||
initialValue: defaultAudioQa,
|
initialValue: defaultAudioQa,
|
||||||
icon: const Icon(Icons.arrow_forward_rounded, size: 22),
|
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||||
onSelected: (item) {
|
onSelected: (item) {
|
||||||
defaultAudioQa = item;
|
defaultAudioQa = item;
|
||||||
setting.put(SettingBoxKey.defaultAudioQa, item);
|
setting.put(SettingBoxKey.defaultAudioQa, item);
|
||||||
@ -119,7 +123,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
),
|
),
|
||||||
trailing: PopupMenuButton(
|
trailing: PopupMenuButton(
|
||||||
initialValue: defaultDecode,
|
initialValue: defaultDecode,
|
||||||
icon: const Icon(Icons.arrow_forward_rounded, size: 22),
|
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||||
onSelected: (item) {
|
onSelected: (item) {
|
||||||
defaultDecode = item;
|
defaultDecode = item;
|
||||||
setting.put(SettingBoxKey.defaultDecode, item);
|
setting.put(SettingBoxKey.defaultDecode, item);
|
||||||
@ -135,6 +139,33 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('默认全屏方式', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'当前全屏方式:' +
|
||||||
|
FullScreenModeCode.fromCode(defaultFullScreenMode)!
|
||||||
|
.description,
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
trailing: PopupMenuButton(
|
||||||
|
initialValue: defaultFullScreenMode,
|
||||||
|
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||||
|
onSelected: (item) {
|
||||||
|
defaultFullScreenMode = item;
|
||||||
|
setting.put(SettingBoxKey.fullScreenMode, item);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||||
|
for (var i in FullScreenMode.values) ...[
|
||||||
|
PopupMenuItem(
|
||||||
|
value: i.code,
|
||||||
|
child: Text(i.description),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,3 +7,20 @@ enum FullScreenMode {
|
|||||||
// 始终横屏
|
// 始终横屏
|
||||||
horizontal
|
horizontal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension FullScreenModeDesc on FullScreenMode {
|
||||||
|
String get description => ['自适应', '始终竖屏', '始终横屏'][index];
|
||||||
|
}
|
||||||
|
|
||||||
|
extension FullScreenModeCode on FullScreenMode {
|
||||||
|
static final List<int> _codeList = [0, 1, 2];
|
||||||
|
int get code => _codeList[index];
|
||||||
|
|
||||||
|
static FullScreenMode? fromCode(int code) {
|
||||||
|
final index = _codeList.indexOf(code);
|
||||||
|
if (index != -1) {
|
||||||
|
return FullScreenMode.values[index];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -5,14 +5,17 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
import 'package:media_kit/media_kit.dart';
|
import 'package:media_kit/media_kit.dart';
|
||||||
import 'package:media_kit_video/media_kit_video.dart';
|
import 'package:media_kit_video/media_kit_video.dart';
|
||||||
import 'package:pilipala/common/widgets/app_bar_ani.dart';
|
import 'package:pilipala/common/widgets/app_bar_ani.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/controller.dart';
|
import 'package:pilipala/plugin/pl_player/controller.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/duration.dart';
|
import 'package:pilipala/plugin/pl_player/models/duration.dart';
|
||||||
|
import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/play_status.dart';
|
import 'package:pilipala/plugin/pl_player/models/play_status.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/utils.dart';
|
import 'package:pilipala/plugin/pl_player/utils.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.dart';
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
import 'package:volume_controller/volume_controller.dart';
|
import 'package:volume_controller/volume_controller.dart';
|
||||||
|
|
||||||
@ -62,6 +65,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
bool _volumeInterceptEventStream = false;
|
bool _volumeInterceptEventStream = false;
|
||||||
|
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
late FullScreenMode mode;
|
||||||
|
|
||||||
void onDoubleTapSeekBackward() {
|
void onDoubleTapSeekBackward() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_mountSeekBackwardButton = true;
|
_mountSeekBackwardButton = true;
|
||||||
@ -149,16 +155,37 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
Future<void> triggerFullScreen() async {
|
Future<void> triggerFullScreen() async {
|
||||||
PlPlayerController _ = widget.controller;
|
PlPlayerController _ = widget.controller;
|
||||||
|
mode = FullScreenModeCode.fromCode(
|
||||||
|
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
||||||
|
|
||||||
if (!_.isFullScreen.value) {
|
if (!_.isFullScreen.value) {
|
||||||
/// 按照视频宽高比决定全屏方向
|
/// 按照视频宽高比决定全屏方向
|
||||||
if (_.direction.value == 'horizontal') {
|
switch (mode) {
|
||||||
/// 进入全屏
|
case FullScreenMode.auto:
|
||||||
await enterFullScreen();
|
if (_.direction.value == 'horizontal') {
|
||||||
// 横屏
|
/// 进入全屏
|
||||||
// await landScape();
|
await enterFullScreen();
|
||||||
} else {
|
// 横屏
|
||||||
// 竖屏
|
// await landScape();
|
||||||
await verticalScreen();
|
} else {
|
||||||
|
// 竖屏
|
||||||
|
await verticalScreen();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FullScreenMode.vertical:
|
||||||
|
|
||||||
|
/// 进入全屏
|
||||||
|
await enterFullScreen();
|
||||||
|
// 横屏
|
||||||
|
// await landScape();
|
||||||
|
break;
|
||||||
|
case FullScreenMode.horizontal:
|
||||||
|
|
||||||
|
/// 进入全屏
|
||||||
|
await enterFullScreen();
|
||||||
|
// 横屏
|
||||||
|
// await landScape();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_.toggleFullScreen(true);
|
_.toggleFullScreen(true);
|
||||||
|
|||||||
@ -79,6 +79,7 @@ class SettingBoxKey {
|
|||||||
static const String defaultPicQa = 'defaultPicQa';
|
static const String defaultPicQa = 'defaultPicQa';
|
||||||
|
|
||||||
static const String danmakuEnable = 'danmakuEnable';
|
static const String danmakuEnable = 'danmakuEnable';
|
||||||
|
static const String fullScreenMode = 'fullScreenMode';
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalCacheKey {
|
class LocalCacheKey {
|
||||||
|
|||||||
Reference in New Issue
Block a user