Author Topic: MusicBee API  (Read 287261 times)

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
can you explain what you mean by "but can't write a new rating with the API"
eg. what steps you are taking to verify that its not writing the tag.
tags are not written to a playing music file until playback has completed.

Also i expect what boroda74 says is true, and the decimal point needs to be localised (however i think the .NET tostring() does that automatically).
but you might try just using "3" or  using a 0-100 scale
Last Edit: July 01, 2013, 02:00:43 PM by Steven

slimmeke

  • Jr. Member
  • **
  • Posts: 51
With "but can't write a new rating with the API" I mean that I can't change the rating value of the song.

I have test it with 5 0,5 and with the 100 scale. After I have runned the code, I go to the next song. So normally the rating has been saved.
But no rating has saved.

And the toString() function of a float use the . notation of a string :). But with replace you can change the "." to ",".

I have changed the source to:

        public void changeRating(float number)
        {
            String url = mbApiInterface.NowPlaying_GetFileUrl();
            string rating = number.ToString().Replace(".", ",");
            mbApiInterface.Library_SetFileTag(url, MetaDataType.Rating, rating);
        }

But doesn't work.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
as i said i think the .net tostring() function automatically localises the decimal value so you are only making things worse with .Replace(".", ",")
I think that is a red herring.

i will ask again, how are you verifying the rating is not saved?

slimmeke

  • Jr. Member
  • **
  • Posts: 51
I verify it by changing the rating using my source.
Then I wait untill the song ends and after that I check if MusicBee sees any rating.
But without any result thus far.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
you need to call:
Library_CommitTagsToFile(url)

also i am still not clear how you are verifying the rating but as a guess from your response you are simply visually checking the main panel?
if that is the case, then you also need to call:
MB_RefreshPanels() so the main panel refreshes after you have made changes to any tags

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Tnx Steven that did the job.
Guys tnx for your time.
Have a nice day.

Pako

  • Full Member
  • ***
  • Posts: 132
I assumed that the API function Playlist_SetFiles(playlistUrl string, string[] filenames)
works the way that it overwrites the current contents of the playlist.
Now I've tried it and it is really so.
However, it is not very user friendly when I want to add some files.
So I have a feature request:
Can you please incorporate a new function Playlist_AddFiles(playlistUrl string, string[] filenames) ?
It would be ideal if the function automatically avoid duplication.
I got this requirement (add files to the playlist) in EventGhost plugin topic.

Thanks, Pako

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
A question about lyrics: How does MusicBee differ between synchronized and not synchronized lyrics? GetProvider() knows what kind is preferred, but that is only a preference, how does MusicBee know of what kind the returned lyrics are?

As far as I can see, the old plugin doesn't even load synchronized lyrics.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
A question about lyrics: How does MusicBee differ between synchronized and not synchronized lyrics? GetProvider() knows what kind is preferred, but that is only a preference, how does MusicBee know of what kind the returned lyrics are?

As far as I can see, the old plugin doesn't even load synchronized lyrics.
disregard that parameter as it was never implemented. I recommend you return synchronised lyrics if there is a choice.
MB automatically detects and parses synchronised lyrics eg. somethimes they are available on the lrc123.com website for example.

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
Can you please incorporate a new function Playlist_AddFiles(playlistUrl string, string[] filenames) ?
It would be ideal if the function automatically avoid duplication.
that has been included in the next v2.2 update. I will make it available in a day or two

Pako

  • Full Member
  • ***
  • Posts: 132
Quote from: Steven
Quote from: Pako
Can you please incorporate a new function Playlist_AddFiles(playlistUrl string, string[] filenames) ?
It would be ideal if the function automatically avoid duplication.
that has been included in the next v2.2 update. I will make it available in a day or two
That's great, thank you very much.
I got it working even without the new function but I will change it (very happy).

Pako

Pako

  • Full Member
  • ***
  • Posts: 132
Can you please incorporate a new function Playlist_AddFiles(playlistUrl string, string[] filenames) ?
It would be ideal if the function automatically avoid duplication.
that has been included in the next v2.2 update. I will make it available in a day or two
According to the log file (which is part of the EventGhost plugin), I see that API revision = 31 and Interface version = 27.
But when I download a C# Source.zip file from http://getmusicbee.com/forum/index.php?topic=1972.0, so there are still older version.
Can you please update?
But maybe I misunderstood something, then I apologize.

Thanks, Pako

e-motiv

  • Full Member
  • ***
  • Posts: 188
Does anyone know: How do you tell MusicBee again your plugin failed to Initialise?

More detail:
I am writing a (storage) plugin and in the Initialise method I also check if all files and databases are accessible (even making backups). But when they don't check out I don't want the plugin to do anything anymore.  Since I cannot return false (PluginInfo expected) and since there is no failed-indication in the PluginInfo type either, I dunno how to go about this. I can do `mbAPI.MB_SendNotification(CallbackType.StorageFailed);`. 
Is that right and enough for a storage plugin? And what if my plugin was not a storage plugin (for the wiki)?
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34346
you can review the subsonic plugin source code to see how a storage plugin should work:
http://www.mediafire.com/download/wh43lpnbzrpboaf/SubSonic.zip