diff --git a/lib/pages/setting/models/video_settings.dart b/lib/pages/setting/models/video_settings.dart index 2136518ea..1888ffabc 100644 --- a/lib/pages/setting/models/video_settings.dart +++ b/lib/pages/setting/models/video_settings.dart @@ -127,10 +127,8 @@ List get videoSettings => [ NormalModel( title: '首选解码格式', leading: const Icon(Icons.movie_creation_outlined), - getSubtitle: () { - final list = Pref.preferCodecs; - return '首选解码格式:${(list.isEmpty ? '第一个可用' : list.map((i) => i.name).join(","))},请根据设备支持情况与需求调整'; - }, + getSubtitle: () => + '首选解码格式:${(Pref.preferCodecs.map((i) => i.name).join(","))},请根据设备支持情况与需求调整', onTap: _showCodecsDialog, ), if (kDebugMode || Platform.isAndroid) @@ -356,13 +354,11 @@ Future _showCodecsDialog( values: {for (final e in VideoDecodeFormatType.values) e: e.name}, ), ); - if (res != null) { - await (res.isEmpty - ? GStorage.setting.delete(SettingBoxKey.preferCodecs) - : GStorage.setting.put( - SettingBoxKey.preferCodecs, - res.map((i) => i.name).toList(), - )); + if (res != null && res.isNotEmpty) { + await GStorage.setting.put( + SettingBoxKey.preferCodecs, + res.map((i) => i.name).toList(), + ); setState(); } } diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 14cdff96a..e6a0ddae7 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -267,10 +267,10 @@ abstract final class Pref { } final codecs = _setting.get(SettingBoxKey.preferCodecs); - if (codecs is List && codecs.isNotEmpty) { + if (codecs is List) { return codecs.map((i) => VideoDecodeFormatType.values.byName(i)).toList(); } - return const []; + return const [.AVC, .AV1]; } static String get hardwareDecoding => _setting.get(