feat: codec list options

This commit is contained in:
My-Responsitories
2026-06-24 01:07:11 +08:00
parent cd3b0547a2
commit dee3580c4a
7 changed files with 140 additions and 170 deletions

View File

@@ -8,8 +8,7 @@ abstract final class SettingBoxKey {
defaultAudioQaCellular = 'defaultAudioQaCellular',
autoPlayEnable = 'autoPlayEnable',
fullScreenMode = 'fullScreenMode',
defaultDecode = 'defaultDecode',
secondDecode = 'secondDecode',
preferCodecs = 'preferCodecs',
defaultToastOp = 'defaultToastOp',
defaultPicQa = 'defaultPicQa',
enableHA = 'enableHA',

View File

@@ -245,15 +245,33 @@ abstract final class Pref {
defaultValue: AudioQuality.k192.code,
);
static String get defaultDecode => _setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormatType.AVC.codes.first,
);
static List<VideoDecodeFormatType> get preferCodecs {
// TODO: remove next 2 version
if (_setting.get('defaultDecode') case String codecStr) {
String? codecStr2 = _setting.get('secondDecode');
_setting.deleteAll(const ['defaultDecode', 'secondDecode']);
final codecs = [
VideoDecodeFormatType.values.firstWhere(
(i) => i.codes.contains(codecStr),
),
if (codecStr2 != null && codecStr2 != codecStr)
VideoDecodeFormatType.values.firstWhere(
(i) => i.codes.contains(codecStr2),
),
];
_setting.put(
SettingBoxKey.preferCodecs,
codecs.map((i) => i.name).toList(),
);
return codecs;
}
static String get secondDecode => _setting.get(
SettingBoxKey.secondDecode,
defaultValue: VideoDecodeFormatType.AV1.codes.first,
);
final codecs = _setting.get(SettingBoxKey.preferCodecs);
if (codecs is List && codecs.isNotEmpty) {
return codecs.map((i) => VideoDecodeFormatType.values.byName(i)).toList();
}
return const [];
}
static String get hardwareDecoding => _setting.get(
SettingBoxKey.hardwareDecoding,