Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from moffatman/master
Browse files Browse the repository at this point in the history
Parse PicType, fix picture on ID3v2.2
  • Loading branch information
sanket143 authored Aug 31, 2021
2 parents d0a24ae + bb54958 commit 2cd0528
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/id3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
25 changes: 25 additions & 0 deletions lib/src/const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};

0 comments on commit 2cd0528

Please sign in to comment.