Jaudiotagger getAll(FieldKey.COMMENT) yields an array of 0s and 1s

145 views Asked by At

I am using JAudioTagger in my Java application to retrieve metadata from an mp3 file. I am able to retrive all metadata within the ID3 without a problem except for the "comments". Comments are something that I added from iTunes by selecting the track, right click on it and get info. Add the comments and save. The problem is before the actual comment can be printed out, the comment field from the below code gives me an array of 0s and 1s of size 4 where index 3 is the actual comment and indices 0 to 2 are array of 0s and 1s. Here is my code to extract/print the comment field:

Tag tag = null;
file = /some/path/file-name.mp3

System.out.println("tag.getAll(FieldKey.COMMENT)-->" + tag.getAll(FieldKey.COMMENT));   // Check output 1 below
System.out.println("tag.getFirst ? "+tag.getFirst(FieldKey.COMMENT) ); // output 2 below

Here are the respective outputs:

// Output for System.out 1
[0,
 00000368 000002C0 00003670 00003005 0001DC53 0001DC53 00008489 00008566 000378AC 00038CE0,
 00000000 00000210 00000A8D 0000000000E16863 00000000
00A37EB2 00000000 00000000 00000000 00000000 00000000 00000000,
 This is a comment ]
// Output for System.out 2
0

Notice how an array is created in the output #1 before the last index which is the actual comment. On further investigation, I found out that the indices 0 to 2 are the exact same as the iTunSMPB field in the ID3, whatever that is supposed to mean. If the file has no comment then the getAll(FieldKey.COMMENT) will result in the same array without the comment of size 3.

Any idea why the extra 0s and 1s are appended. I don't wish to hardcode the index 3 to extract the intended comment.

1

There are 1 answers

0
Dan Gravell On

This is because iTunes extra fields like iTunSMPB (also iTunNORM, iTunPGAP et al) are stored in a comments field with the COMMENT frame key, but with specific sub keys.

You could try filtering the returned TagFields.