Author Topic: MusicBee API  (Read 287275 times)


Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34348
i dont think i can help you any further with this then

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
Oh you definitly can! Give more informations about the error. Either in the message box or in the log file. The plugin starts if I call init from Initialise(), but fails when I disable it and then try to re-enable it. Testing it with a unit test works fine.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
As far as I remember Initialise() is called only ones when plugin is initialized first time. Second time and so on only NotificationType.PluginStartup event is sent to plugin.


Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34348
for 1, having a quick look at the code you should move the initialisation logic to NotificationType.PluginStartup in ReceiveNotification(...)
the Initialise(...) function only gets called once whereas NotificationType.PluginStartup is called each time the plugin is enabled and wont be called if the plugin is disabled.
I doubt there is any error - doing it the way you have done it means your initialise function wont be called the 2nd and subsequent re-enables.
Also i realise now what probably is the cause of the unexpected behavior is that the GetProviders() function can be called before before the ReceiveNotification function is called because of the way its implemented. I accept that undesirable behavior but there are too many plugins now to change it. My suggestion is to test if initialisation required on both. Please dont implement it where you have as that will slow down the load of MB and will be called even if the user has disabled the plugin.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
This wont work on vista/7 until you run MB as administrator:
Code
this.logger = new Logger(this.pluginDirectory + Path.DirectorySeparatorChar + this.name + ".log");
Use Setting_GetPersistentStoragePath() to get writable application directory.

At this moment I dont see anything else strange. The good decision is to use try-catch construction in Initialise() plugin function to write errors to log or display them on screen.

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
This wont work on vista/7 until you run MB as administrator:
Code
this.logger = new Logger(this.pluginDirectory + Path.DirectorySeparatorChar + this.name + ".log");
Use Setting_GetPersistentStoragePath() to get writable application directory.

Fixed that, thanks for the notice. The first thing I do after installing windows is disabling the UAC.

@Steven: Just provide more information when a plugin fails to enable.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
@Steven: Just provide more information when a plugin fails to enable.
Use "try {...} catch (Exception e) {MessageBox.Show(e.Message)}" in the Initialise() function.

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
Sure but still it would be better to have more information about the errors from the MusicBee side

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
@Steven seems like you were wrong: Initialise(IntPtr) is called every time the plugin is enabled, and Close(PluginCloseReason) on every disable.

slimmeke

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

I have a problem using the rate function of the MusicBee API. I can read the rating but can't write a new rating with the API.
I use fowolling code:

mbApiInterface.Library_SetFileTag(mbApiInterface.NowPlaying_GetFileUrl(), MetaDataType.Rating, "3.5");

Is this correct or is this the wrong way to do this?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
1. What are localizations of your MB & windows? Probably you need to call:

mbApiInterface.Library_SetFileTag(mbApiInterface.NowPlaying_GetFileUrl(), MetaDataType.Rating, "3,5");

2. Note that tag changes (writing changes to file) for now playing track can be delayed until next track is played.

slimmeke

  • Jr. Member
  • **
  • Posts: 51
I have tested this but doesn't work  :-[.

slimmeke

  • Jr. Member
  • **
  • Posts: 51
Can nobody help me with this rating problem?
This is the only bug that is in my next release of the Logitech Plugin.
When I fix this I can release it.