feat: 调整设置,支持导入导出,代码优化

This commit is contained in:
orz12
2024-04-27 02:05:50 +08:00
parent a4d3713b05
commit ea8f44f4da
41 changed files with 882 additions and 424 deletions

View File

@@ -21,6 +21,8 @@ class _VideoSettingState extends State<VideoSetting> {
late dynamic defaultAudioQa;
late dynamic defaultDecode;
late dynamic secondDecode;
late dynamic hardwareDecoding;
late dynamic videoSync;
@override
void initState() {
@@ -33,6 +35,10 @@ class _VideoSettingState extends State<VideoSetting> {
defaultValue: VideoDecodeFormats.values.last.code);
secondDecode = setting.get(SettingBoxKey.secondDecode,
defaultValue: VideoDecodeFormats.values[1].code);
hardwareDecoding = setting.get(SettingBoxKey.hardwareDecoding,
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
videoSync =
setting.get(SettingBoxKey.videoSync, defaultValue: 'display-resample');
}
@override
@@ -55,31 +61,36 @@ class _VideoSettingState extends State<VideoSetting> {
children: [
const SetSwitchItem(
title: '开启硬解',
subTitle: '以较低功耗播放视频,若异常卡死,请尝试关闭',
subTitle: '以较低功耗播放视频,若异常卡死关闭',
leading: Icon(Icons.flash_on_outlined),
setKey: SettingBoxKey.enableHA,
defaultVal: true,
),
const SetSwitchItem(
title: '亮度记忆',
subTitle: '返回时自动调整视频亮度',
leading: Icon(Icons.brightness_6_outlined),
setKey: SettingBoxKey.enableAutoBrightness,
defaultVal: false,
),
const SetSwitchItem(
title: '免登录1080P',
subTitle: '免登录查看1080P视频',
leading: Icon(Icons.hd_outlined),
setKey: SettingBoxKey.p1080,
defaultVal: true,
),
const SetSwitchItem(
title: 'CDN优化',
subTitle: '使用优质CDN线路',
leading: Icon(Icons.network_check_outlined),
setKey: SettingBoxKey.enableCDN,
defaultVal: true,
),
ListTile(
dense: false,
title: Text('默认画质', style: titleStyle),
leading: const Icon(Icons.video_settings_outlined),
subtitle: Text(
'当前画质:${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
style: subTitleStyle,
@@ -106,6 +117,7 @@ class _VideoSettingState extends State<VideoSetting> {
ListTile(
dense: false,
title: Text('默认音质', style: titleStyle),
leading: const Icon(Icons.audiotrack_outlined),
subtitle: Text(
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
style: subTitleStyle,
@@ -132,6 +144,7 @@ class _VideoSettingState extends State<VideoSetting> {
ListTile(
dense: false,
title: Text('首选解码格式', style: titleStyle),
leading: const Icon(Icons.movie_creation_outlined),
subtitle: Text(
'首选解码格式:${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!},请根据设备支持情况与需求调整',
style: subTitleStyle,
@@ -162,6 +175,7 @@ class _VideoSettingState extends State<VideoSetting> {
'非杜比视频次选:${VideoDecodeFormatsCode.fromCode(secondDecode)!.description!},仍无则选择首个提供的解码格式',
style: subTitleStyle,
),
leading: const Icon(Icons.swap_horizontal_circle_outlined),
onTap: () async {
String? result = await showDialog(
context: context,
@@ -184,16 +198,84 @@ class _VideoSettingState extends State<VideoSetting> {
if (Platform.isAndroid)
const SetSwitchItem(
title: '优先使用 OpenSL ES 输出音频',
leading: Icon(Icons.speaker_outlined),
subTitle: '关闭则优先使用AudioTrack输出音频此项即mpv的--ao',
setKey: SettingBoxKey.useOpenSLES,
defaultVal: true,
),
const SetSwitchItem(
title: '扩大缓冲区',
subTitle: '默认缓冲区为视频5MB/直播32MB开启后为视频32MB/直播64MB但会延长首次加载时间',
leading: Icon(Icons.storage_outlined),
subTitle: '默认缓冲区为视频5MB/直播32MB开启后为32MB/64MB加载时间变长',
setKey: SettingBoxKey.expandBuffer,
defaultVal: false,
),
//video-sync
ListTile(
dense: false,
title: Text('视频同步', style: titleStyle),
leading: const Icon(Icons.view_timeline_outlined),
subtitle: Text(
'当前:$videoSync此项即mpv的--video-sync',
style: subTitleStyle,
),
onTap: () async {
String? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<String>(
title: '视频同步',
value: videoSync,
values: [
'audio',
'display-resample',
'display-resample-vdrop',
'display-resample-desync',
'display-tempo',
'display-vdrop',
'display-adrop',
'display-desync',
'desync'
].map((e) {
return {'title': e, 'value': e};
}).toList());
},
);
if (result != null) {
setting.put(SettingBoxKey.videoSync, result);
videoSync = result;
setState(() {});
}
},
),
ListTile(
dense: false,
title: Text('硬解模式', style: titleStyle),
leading: const Icon(Icons.memory_outlined),
subtitle: Text(
'当前:$hardwareDecoding此项即mpv的--hwdec',
style: subTitleStyle,
),
onTap: () async {
String? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<String>(
title: '硬解模式',
value: hardwareDecoding,
values: ['auto', 'auto-copy', 'auto-safe', 'no', 'yes']
.map((e) {
return {'title': e, 'value': e};
}).toList());
},
);
if (result != null) {
setting.put(SettingBoxKey.hardwareDecoding, result);
hardwareDecoding = result;
setState(() {});
}
},
),
],
),
);