Read Write MP3 ID3 Rating Stars Tag

This doesn’t appear to be an easy thing to do. I’ve tried MBS plugins but it doesn’t seem to support the star rating tags. Best I could find is an old VB6 project that has windows dependancies.

1 Like

star rating tags?

if you load such a file and you look into Properties dictionary, the rating is not there in one of the fields?

My experience with iTunes/Music is that I’ve moved my files several times in other drives and, when I reimported the files (because iTunes/Music couldn’t resolve the old ones it knew), the tags were almost all back, except ratings and a few others. At that time, I assumed they were stored in the iTunes/Music library file and possibly not a standard file tag :man_shrugging:.

It’s true, there’s no standard way of doing it but there’s a field in ID3v2 called POPM that a lot of players use to store a value between 0-255. Problem is the byte location is not consistant.

I found a VB6 example project that reads it so I’ll look into that.

1 Like

I actually wrote an ID3 tag extractor entirely in Xojo native code. The ID3 tag structure is actually not that complicated: basically a 10-byte header plus variable bytes of data (the number of bytes are in the header). I created a simple class that takes a FolderItem as an input, and adds all ID3 tags to a dictionary property of the class called “ID3Tags”.

If interested, I’ve included a link where can download my project.

Xojo ID3 Tags Example Binary Project … download it here

The real difficulty I ran into was the encoding of the text (sometimes UTF, sometimes not). To simplify the output, I basically run all the data through Xojo’s “.ToText”.

You could reverse what I’ve done in reading the tags to add (write) new ID3 frames.

Some of the specs I used are here:

Anyway, hopefully this can help someone.


thanks a lot!, works great ! tried with a bunch of files

there seems to be something wierd with the tag “date”, or it’s normal ? i had this in couple files

Thank you a lot! It’s been a long time since I looked for such capabilities but hadn’t time to study the format (doing too much things).

That’s awesome, Thanks for sharing.

Date is supposed to be the year of production. But some people overload the tags for their own purposes, so the data itself isn’t validated in any way … i.e. it can be anything.

Also, I’ve updated the class so that it now correctly extracts images from the files … I will post the new file here in an hour or so of those interested. Thanks!

I updated the ID3 tags extractor sample project so that it now can read images (album art). The project also includes a canvas, and shows how to place the image data and resize it (another common need). Same link as before, but here it is again:

Xojo ID3 Tags Example Binary Project … download it here

Example screen shot of new project:


great thanks !
but there’s seem to be a padding problem sometimes, it repeats characters, you can see pattern below :

i can send you some files if you want

1 Like

Please re-download the project from my site. There was indeed a UTF-BOM bug that I had found/fixed, but you “got lucky,” and downloaded the project before I updated it. :slight_smile:

1 Like

I really like this program, Edward! Thanks!

As a hobby project for my own use I’m writing a music program a bit like iTunes/Apple Music that plays from the iTunes/Music library. Check out this topic for more info: Cenojuke player

Eventually I want it to become a separate program with it’s own library and file management system, so I needed code to read mp3 tags to extract info from the music files and I also wanted to show the cover art from within the mp3 file. When I ran into your software I was super excited and actually got it running in my software within half an hour! You can see the cover art working with your code in this screenshot:

But I noticed that your program is not reading the cover art from all mp3 files? It may not support some formats? I was wondering if you expanded your code since the last time you’ve created and posted it?

Thank you for the nice words and for your interest! Yes, I have expanded it, and I will post the updated version in a few minutes. The latest version now extracts all of the embedded images, and optionally can include sidecar images, as well. I also reworked the ID3 reader to better handle binary data and UTF text. The official ID3 headers are not all implemented, but I haven’t had any problems in my media player app for several months (and I use it daily).

Thanks!! I forgot to ask: is it oké if I use your code for my program?

Strange thing is that it seems to work better on recent mp3 files and skips the cover art on older files.

From these files it only shows covert art from the first song, while all files show cover art in my Mac’s Finder screen (although “Lena” doesn’t show cover art in the mp3tag software, where this screen capture came from). I guess mp3 tags have many different forms :sweat_smile:

Yes … I released this as CC0 (i.e. public domain) … thanks for asking! And the latest version is now posted:

ID3 images are embedded with the APIC tag. The image mime type is included, and is typically JPEG or PNG. The EKMediaFile object is format agnostic, and should extract any image’s binary data. But that data is then passed to Picture.FromData() to be displayed on a canvas, and is therefore limited to whatever formats are supported by that function.

Furthermore, the EKMediaFile.ID3Images() is an array of MemoryBlocks that contain the raw binary of each embedded image. If you need to check the embedded file type, you can read the first few bytes of each MemoryBlock to get the file header, which will reliably indicate its file type even if the mime type is incorrect.


The new code returns more info from the ID3 tags, but it returns images for the same mp3’s as the old code did, so no visible improvements there. I guess not all ID3 formats/versions are supported. If I add cover art with the mp3tag editor software then all these mp3’s work after that, so I guess that software uses the most recent ID3 version that also works with your code.

In order to identify the issue, you’d have to look at the binary data in the Xojo debugger. If you could post a screen shot of the ID3Images(0) binary data for that file, it might help determine if the embedded image is a Xojo-supported format or not. Or, if the ID3Images() array is empty, then it would indicate that the embedded art is not properly embedded (using an APIC tag).

Otherwise, I’d have to get my hands on the actual file, and look at it in a hex-reader.

I have posted both mp3 files in my public Dropbox folder since I can’t seem to figure out what’s wrong with them :thinking:

file 1

file 2

I also found out that:
" ID3v2.3 is the most widely used version of ID3v2 tags and is widely supported by Windows Explorer and Windows Media Player.[10] Notably it introduced the ability to embed an image such as an album cover."

So that kind of answers my question: the first file is a ID3v2.2 file that does not (officially) support cover art and the second is ID3v2.4 which is not supported by your software because it’s not widely used. I also have a lot of M4A files and those have a totally different header formatting altogether. But I DO wonder why my v2.2 mp3 IS showing cover art in the Finder screen… :smile:

Complicated stuff… But your routine works flawlessly when the file has an ID3v2.3 tag! So I will look into converting everything to that.

Looking through my music library I notice that I have A LOT of mp3 files with ID3v2.4 tags. I mostly use your code to extract the cover art and that does not seem to work with these ID3v2.4 tagged mp3’s. I read that v2.4 is very similar to v2.3 but there are some small differences, like encoding. Would you be able to see the difference with the files I have sent you and a hex reader?