fix(metadata): resolve audio format and local artwork

This commit is contained in:
zarzet
2026-07-22 15:55:30 +07:00
parent b2726db84a
commit 87376ee73b
5 changed files with 72 additions and 43 deletions
+13
View File
@@ -54,6 +54,8 @@ String? normalizeAudioFormatValue(String? value) {
return switch (normalized) {
'flac' => 'flac',
'alac' => 'alac',
'wav' || 'wave' => 'wav',
'aiff' || 'aif' || 'aifc' => 'aiff',
'aac' || 'mp4a' => 'aac',
'eac3' || 'ec_3' => 'eac3',
'ac3' || 'ac_3' => 'ac3',
@@ -65,6 +67,17 @@ String? normalizeAudioFormatValue(String? value) {
};
}
/// Resolves the actual audio codec reported by native metadata probing, while
/// falling back to the container format when the codec is absent or generic.
///
/// This distinction matters for MP4/M4A files: the same container may hold
/// AAC, ALAC, Dolby, or other codecs.
String? detectedAudioFormatFromMetadata(Map<String, dynamic> metadata) {
final codec = normalizeAudioFormatValue(metadata['audio_codec']?.toString());
if (codec != null) return codec;
return normalizeAudioFormatValue(metadata['format']?.toString());
}
bool isLossyAudioFormat(String? value) {
return const {
'aac',