如何使用Java MP3 ID3标记库来检索专辑图片 [英] How to use the Java MP3 ID3 Tag Library to retrieve album artwork

查看:150
本文介绍了如何使用Java MP3 ID3标记库来检索专辑图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个MP3播放器。我正在使用 Java mp3 id3标记库。我知道专辑图片被编码为ID3v2标签。

I'm making an mp3 player. I'm using the Java mp3 id3 tag library. I understand that album artwork is encoded as a ID3v2 tag.

我可以访问mp3文件的ID3v2标签但是我无法获得艺术品!
AbstractID3v2类中的
API 中的所有方法似乎都没有检索到图片。

I can access the ID3v2 tag of a mp3 file however I cannot get the artwork! None of the methods in the AbstractID3v2 class, in the API seem to retrieve a picture.

如何使用这个库?

推荐答案

我最后使用另一个库,我使用 mp3agic

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));
}

这篇关于如何使用Java MP3 ID3标记库来检索专辑图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆