I am trying to read ID3 from a mp3 file thats locally stored in the SD card.
I want to basically fetch
- Title
- Artist
- Album
- Track Length
- Album Art
I am trying to read ID3 from a mp3 file thats locally stored in the SD card.
I want to basically fetch
You can get all of this using MediaMetadataRetriever
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(filePath);
String albumName =
mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
null
), despite the fact that I do see id3 tags with other software... –
Ossa null
almost everywhere). –
Ossa 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.
InputStream
from the file and a 128 byte buffer; read the last 128 bytes into the buffer; check the first 3 bytes of the buffer, should be TAG
; read the relevant bytes using Arrays.copyOfRange
; convert those bytes to int
(for genre) or String
(for everything else). –
Bergren 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...
© 2022 - 2024 — McMap. All rights reserved.