The tag information (song name, album name, artist name, etc.) of the song file can be easily edited from various media players.
Especially in iTunes, it is very convenient to use
Gracenote to automatically acquire tag information at the same time as importing from a CD.
However, in some cases, the acquired tag information may be __ not your favorite __.
To give an example
It is troublesome to edit these songs one by one, so I always wanted to be able to manipulate the tag information from the system. (Although you will also need CDDB that meets the above requirements ...)
This time, regarding the
processing to get the tag information from the manipulating the tag information from the system
, the result of verifying the library called JAudioTagger
with the combination of theJava language
and SpringBoot` is left as a memorandum.
Add the following dependencies to
<dependency> <groupId>org</groupId> <artifactId>jaudiotagger</artifactId> <version>2.0.3</version> </dependency>
First, check the tag information of the appropriate song imported into iTunes
Now let's actually read the tag information from the Java code (see below for the code)
AudioFile audioFile = AudioFileIO.read(File object that reads a music file); Tag tag = audioFile.getTag(); System.out.println(tag.getFirst(FieldKey.TITLE)); System.out.println(tag.getFirst(FieldKey.ARTIST)); System.out.println(tag.getFirst(FieldKey.ALBUM_ARTIST)); System.out.println(tag.getFirst(FieldKey.ALBUM)); System.out.println(tag.getFirst(FieldKey.YEAR)); System.out.println(tag.getFirst(FieldKey.COMPOSER)); System.out.println(tag.getFirst(FieldKey.GENRE));
The output result is as follows.
Who will ring the bell? Keyakizaka46 Keyakizaka46 Who will ring the bell? 2020 Yuki Tsujimura J-POP
By the way,
FieldKey seems to be able to get something like the following
|FieldKey||Tag information that can be obtained|
|YEAR||Album release year|
It seems that you can get various other fields (Reference: Mapping table)
This time I verified
getting tag information, but next I would like to verify
writing tag information
. Also, I would like to verify the operation of tag information in languages other than Java` when I have time.
Last but not least, with subscriptions becoming mainstream these days, manipulating local music files may be nonsense (laughs).