diff --git a/lib/id3.dart b/lib/id3.dart index 66d0b8c..9cb88bf 100644 --- a/lib/id3.dart +++ b/lib/id3.dart @@ -227,8 +227,14 @@ class MP3Instance { final frame = _MP3FrameParser(frameContent); frame.readEncoding(); - apic['mime'] = frame.readLatin1String(); - apic['description'] = frame.readString(); + // In ID3v2.2 the MIME type is always 3 characters + if (major_v == 2) { + apic['mime'] = latin1.decode(frame.readBytes(3)); + } else { + apic['mime'] = frame.readLatin1String(); + } + apic['picType'] = PICTYPE[frame.readBytes(1).first] ?? 'Unknown'; + apic['description'] = frame.readString(checkEncoding: false); apic['base64'] = base64.encode(frame.readRemainingBytes()); metaTags['APIC'] = apic; } else if (frames_db[latin1.decode(frameName)] == FRAMESv2_3['USLT']) { diff --git a/lib/src/const.dart b/lib/src/const.dart index 74262b8..5c24fb6 100644 --- a/lib/src/const.dart +++ b/lib/src/const.dart @@ -211,3 +211,28 @@ const GENREv1 = [ 'Rock ā€™nā€™ Roll', 'Hard Rock' ]; + +const PICTYPE = { + 0x00: 'Other', + 0x01: 'FileIcon', + 0x02: 'OtherFileIcon', + 0x03: 'FrontCover', + 0x04: 'BackCover', + 0x05: 'LeafletPage', + 0x06: 'Media (e.g. lable side of CD)', + 0x07: 'LeadArtist', + 0x08: 'Artist', + 0x09: 'Conductor', + 0x0A: 'Band', + 0x0B: 'Composer', + 0x0C: 'Lyricist', + 0x0D: 'RecordingLocation', + 0x0E: 'DuringRecording', + 0x0F: 'DuringPerformance', + 0x10: 'VideoStill', + // Might be a joke but it's in the ID3 spec + 0x11: 'ABrightColouredFish', + 0x12: 'Illustration', + 0x13: 'ArtistLogo', + 0x14: 'PublisherLogo' +};