Author Topic: MusicBee API  (Read 285429 times)

jorgejiro

  • Guest
YEESSSS!

It works, thank you Steven for your quick response and great work!

I've used the way you told me, registering the command using "MB_RegisterCommand" :)

Thank you very much! I suppose I have to publish it under the "Plugins" sections...

boroda

  • Sr. Member
  • ****
  • Posts: 4595
Steven, is it possible to read 'Loved'/'Banned' tags with current API?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
yes, its already in the interface definition file:
public enum MetaDataType
  RatingLove = 76

with returns "L", "B" or blank

if you want to set the value, you can but it only updates the cache.
If you want it to update last.fm as well then send me a PM

boroda

  • Sr. Member
  • ****
  • Posts: 4595
yes, its already in the interface definition file:
public enum MetaDataType
  RatingLove = 76

with returns "L", "B" or blank
Thank you

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Hey

I have 2 problems with the API at the moment. When the user changed the tags of the current playing track hte API must hit "NotificationType.TagsChanged" but in my case it doesn't. Is this a known bug or is it my code?
The code below is my code for it:
     case NotificationType.TagsChanged:
                case NotificationType.NowPlayingArtworkReady:
                 case NotificationType.RatingChanged:
                case NotificationType.TrackChanged:
                    string artist = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Artist);
                    string album = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Album);
                    string title = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.TrackTitle);
                    string artwork = mbApiInterface.NowPlaying_GetArtwork();
                    string rating = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Rating);
                    string playlist = mbApiInterface.Playlist_QueryGetAllFiles();

                    logitech.changeArtistTitle(artist, album, title, rating, artwork, mbApiInterface.NowPlaying_GetDuration()/1000, mbApiInterface.Player_GetPosition()/1000);
                    break;
            }

Second problem is setting the rating of the current playing track. I use following code but it doesn't work.

foalt number = 0.5f;
String url = mbApiInterface.NowPlaying_GetFileUrl();
            mbApiInterface.Library_SetFileTag(url, MetaDataType.Rating, number.ToString());

Can someone help me with those problems. Tnx a lot for your time.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
TagsChanged event is fired when tags are actually written to file. For currently played file it will be when next track is played. TagsChanging event is fired when new tags values are enqueued for writing. For tracks which are not played TagsChanged and TagsChanging events are identical.   

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Oh didn't know that. Tnx for it.

Is this also why the rating doesn't work or is it an other problem??
Last Edit: March 22, 2013, 01:15:40 PM by slimmeke

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Is there a NotificationType for changing the settings like repeat, AutoDj, ...? I have found it only for the autoDj but not for the other settings that can be changed using this API.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i will put a notification in the next 2.1 update
just add these enums to public enum NotificationType
            PlayerRepeatChanged = 20,
            PlayerShuffleChanged = 21

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Tnx for your support.
But sorry for asking is it possible to also add a Notification type for enabling and disabling the equaliser?
If this added to the API than I can make my plugin even better :).

Tnx Steven for your great work.
Last Edit: March 24, 2013, 11:41:30 AM by slimmeke

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
you can already get the auto-dj notification
        AutoDjStarted = 3
        AutoDjStopped = 4

i have also added
            PlayerEqualiserOnOffChanged = 22,
            PlayerScrobbleChanged = 23

slimmeke

  • Jr. Member
  • **
  • Posts: 51

slimmeke

  • Jr. Member
  • **
  • Posts: 51
I think I have found 2 bugs in the API or in MusicBee.
When I do "mbApiInterface.Player_SetRepeat(RepeatMode.One);" MusicBee will set repeat to All instead of One.
And when I do:
 String url = mbApiInterface.NowPlaying_GetFileUrl();
 mbApiInterface.Library_SetFileTag(url, MetaDataType.Rating, number.ToString());
MusicBee does not change the rating of the track.

Is this an issue or is it my code?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
Not sure about 1, didn't test it. But I definitely using 2 in my plugin. There is one issue with rating: if rating <= 5 when writing then rating is multiplied by 20. Read rating belongs to scope 5-100.

slimmeke

  • Jr. Member
  • **
  • Posts: 51
I have tested rating with rang of 5-100, 0-5, 0-10, ... but nothing works. :-[