问题
I want to be able to read ID3v2 tags from mp3 files. I have found multiple frameworks which allow me to get the basic tags. But I would like to be able those in this list. I don't care about backwards compatibility with IDv1.
I already had a look at Jaudiotagger and mp3agic. I didn't find out how to use them for custom tags. Is this possible?
回答1:
You've to use the string identifier "TXXX", that's the main difference between "normal" and custom fields. I think the following code should be self-explanatory:
AudioFile audioFile = AudioFileIO.read(File songFile) // try and catch
MP3File mp3 = (MP3File) audioFile;
AbstractID3v2Tag v2Tag = mp3.getID3v2Tag();
// Since you've mentioned a list
List<TagField> tagList = v2Tag.getFields("TXXX")
That's one way to do it. The List has now all tags with the TXXX identifier. Now you can simply call toString() on every element in the list and you should get something along those lines:
Description="Play Count"; Text="1.000.000"
来源:https://stackoverflow.com/questions/41459061/how-to-read-write-id3v2-tags-with-java