Read ID3 Tags of an MP3 file

北慕城南 提交于 2019-11-27 11:21:29

问题


I am trying to read ID3 from a mp3 file thats locally stored in the SD card.

I want to basically fetch

  1. Title
  2. Artist
  3. Album
  4. Track Length
  5. Album Art

回答1:


You can get all of this using MediaMetadataRetriever

MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(filePath);

String albumName =
     mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);



回答2:


Check the MP3 file format. Basically, you have to read the last 128 bytes of the file; if the first 3 bytes are "TAG", carry on and read the fields you need; if not, the file doesn't have the info attached.




回答3:


if the last 128 byte begins with the token "TAG" the file has an ID3v1 (or ID3v1.1) tag. ID3v2.3 tags are located in the beginning of the file (suitable for streaming) indicated by the token "id3". I believe ID3v2.4 is indicated by "3DE", but i'm not sure...



来源:https://stackoverflow.com/questions/6306636/read-id3-tags-of-an-mp3-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!