How to use the Java MP3 ID3 Tag Library to retrieve album artwork

别来无恙 提交于 2019-12-02 21:50:14

I ended up using another library, I used mp3agic

It's a great library which is easy to use. Here's sample code I used to get the album artwork

Mp3File song = new Mp3File(filename);
if (song.hasId3v2Tag()){
     ID3v2 id3v2tag = song.getId3v2Tag();
     byte[] imageData = id3v2tag.getAlbumImage();
     //converting the bytes to an image
     BufferedImage img = ImageIO.read(new ByteArrayInputStream(imageData));
}

There's also Jaudiotagger which can read/write Mp3, Mp4 (Mp4 audio, M4a and M4p audio) Ogg Vorbis, Flac and Wma + some others (album art too).

MP3File f = (Mp3File)AudioFileIO.read(testFile);
List<Artwork> artworkList;
if (f.hasID3v1Tag()) {
    ID3v1Tag v1tag = f.getID3v1Tag();
    artworkList = (List<Artwork>) v1tag.getArtworkList();
    /* ... */
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!