Hey programming community. So I'm using TagLib Sharp library to fetch the metadata from my .mp3s. Everything is going great with one exception. I can read the rating from my MP3s of they're whole numbers (set my Musicbee). Meaning
Stars
5 = 255
4 = 196
3 = 128
2 = 64
1 = 1
unrated=0
The problem I am running into is I use MusicBee where I can set half star ratings. So the value that I should be getting from my ratings is:
Stars
5 = 255
4.5 = 224
4 = 196
3.5 = 160
3 = 128
2.5 = 96
2 = 64
1.5 = 48
1 = 1
unrated=0
However, this is what TagLib is reading:
5 = 255
4.5 = 0
4 = 196
3.5 = 0
3 = 128
2.5 = 0
2 = 64
1.5 = 0
1 = 1
This is the code that I am using to get the ratings:
TagLib.File file = TagLib.File.Create(fi.FullName);
TagLib.Tag tag = file.GetTag(TagLib.TagTypes.Id3v2);
TagLib.Id3v2.PopularimeterFrame tagInfo = TagLib.Id3v2.PopularimeterFrame.Get((TagLib.Id3v2.Tag)tag, "Windows Media Player 9 Series", true);
byte rate = tagInfo.Rating;
//This is where I'm storing the value as a string to process it later
id3.Rating = tagInfo.Rating.ToString();
My question is, well, two-fold. Is there another usr that I should/could use instead of "Windows Media Player 9 Series"? OR is there a better way that I should be getting the rating from my mp3s? Should I abandon the half-star ratings of Musicbee?
Also, is there a "help" file on taglib? It seems like EVERYTHING that I can find on it is found here. I don't even know what I'm setting to "true" in my code above.
Thank you for your help in advance!
* Update * This is not an answer just fixing a typo from:
1 = 24 to
1 = 1
When using TagLibSharp, the 2nd argument of
TagLib.Id3v2.PopularimeterFrame.Get
should be the value of the "Email to user" field of the POPM frame.This value should be "MusicBee" in your case, and not "Windows Media Player 9 Series".
=> The working code is as follows (tested with real-life MusicBee file)
NB : MusicBee stores "half-stars" with a slightly different convention than the one you imagined : 54 = 1,5 - 118 = 2,5...