feat: 底部播放进度条设置
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/video/play/quality.dart';
|
||||
import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart';
|
||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
import 'widgets/switch_item.dart';
|
||||
@ -19,6 +19,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
late dynamic defaultAudioQa;
|
||||
late dynamic defaultDecode;
|
||||
late int defaultFullScreenMode;
|
||||
late int defaultBtmProgressBehavior;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -31,6 +32,8 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
defaultValue: VideoDecodeFormats.values.last.code);
|
||||
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||
defaultValue: FullScreenMode.values.first.code);
|
||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||
defaultValue: BtmProgresBehavior.values.first.code);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -163,6 +166,31 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
],
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('底部进度条展示', style: titleStyle),
|
||||
subtitle: Text(
|
||||
'当前展示方式:${BtmProgresBehaviorCode.fromCode(defaultBtmProgressBehavior)!.description}',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
trailing: PopupMenuButton(
|
||||
initialValue: defaultBtmProgressBehavior,
|
||||
icon: const Icon(Icons.more_vert_outlined, size: 22),
|
||||
onSelected: (item) {
|
||||
defaultBtmProgressBehavior = item;
|
||||
setting.put(SettingBoxKey.btmProgressBehavior, item);
|
||||
setState(() {});
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||
for (var i in BtmProgresBehavior.values) ...[
|
||||
PopupMenuItem(
|
||||
value: i.code,
|
||||
child: Text(i.description),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -7,6 +7,8 @@ export './models/play_status.dart';
|
||||
export './models/data_status.dart';
|
||||
export './widgets/common_btn.dart';
|
||||
export './models/play_speed.dart';
|
||||
export './models/fullscreen_mode.dart';
|
||||
export './models/bottom_progress_behavior.dart';
|
||||
export './widgets/app_bar_ani.dart';
|
||||
export './utils/fullscreen.dart';
|
||||
export './utils.dart';
|
||||
|
23
lib/plugin/pl_player/models/bottom_progress_behavior.dart
Normal file
23
lib/plugin/pl_player/models/bottom_progress_behavior.dart
Normal file
@ -0,0 +1,23 @@
|
||||
// ignore: camel_case_types
|
||||
enum BtmProgresBehavior {
|
||||
alwaysShow,
|
||||
alwaysHide,
|
||||
onlyShowFullScreen,
|
||||
}
|
||||
|
||||
extension BtmProgresBehaviorDesc on BtmProgresBehavior {
|
||||
String get description => ['始终展示', '始终隐藏', '仅全屏时展示'][index];
|
||||
}
|
||||
|
||||
extension BtmProgresBehaviorCode on BtmProgresBehavior {
|
||||
static final List<int> _codeList = [0, 1, 2];
|
||||
int get code => _codeList[index];
|
||||
|
||||
static BtmProgresBehavior? fromCode(int code) {
|
||||
final index = _codeList.indexOf(code);
|
||||
if (index != -1) {
|
||||
return BtmProgresBehavior.values[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import 'package:pilipala/utils/feed_back.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:screen_brightness/screen_brightness.dart';
|
||||
|
||||
import 'models/bottom_progress_behavior.dart';
|
||||
import 'utils/fullscreen.dart';
|
||||
import 'widgets/app_bar_ani.dart';
|
||||
import 'widgets/backward_seek.dart';
|
||||
@ -67,6 +68,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
|
||||
Box setting = GStrorage.setting;
|
||||
late FullScreenMode mode;
|
||||
late int defaultBtmProgressBehavior;
|
||||
|
||||
void onDoubleTapSeekBackward() {
|
||||
setState(() {
|
||||
@ -87,6 +89,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
vsync: this, duration: const Duration(milliseconds: 300));
|
||||
videoController = widget.controller.videoController!;
|
||||
widget.controller.headerControl = widget.headerControl;
|
||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||
defaultValue: BtmProgresBehavior.values.first.code);
|
||||
|
||||
Future.microtask(() async {
|
||||
try {
|
||||
@ -203,7 +207,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
systemOverlayStyle: SystemUiOverlayStyle.light,
|
||||
),
|
||||
body: SafeArea(
|
||||
bottom: true,
|
||||
bottom: false,
|
||||
child: PLVideoPlayer(
|
||||
controller: _,
|
||||
headerControl: _.headerControl,
|
||||
@ -626,6 +630,15 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
final int value = _.sliderPosition.value.inSeconds;
|
||||
final int max = _.duration.value.inSeconds;
|
||||
final int buffer = _.buffered.value.inSeconds;
|
||||
if (defaultBtmProgressBehavior ==
|
||||
BtmProgresBehavior.alwaysHide.code) {
|
||||
return Container();
|
||||
}
|
||||
if (defaultBtmProgressBehavior ==
|
||||
BtmProgresBehavior.onlyShowFullScreen.code &&
|
||||
!_.isFullScreen.value) {
|
||||
return Container();
|
||||
}
|
||||
if (value > max || max <= 0) {
|
||||
return Container();
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ class SettingBoxKey {
|
||||
|
||||
static const String blackMidsList = 'blackMidsList';
|
||||
static const String autoUpdate = 'autoUpdate';
|
||||
static const String btmProgressBehavior = 'btmProgressBehavior';
|
||||
}
|
||||
|
||||
class LocalCacheKey {
|
||||
|
Reference in New Issue
Block a user