mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-01 06:40:14 +08:00
feat: codec list options
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user