Author Topic: MusicBee API  (Read 287282 times)

boroda

  • Sr. Member
  • ****
  • Posts: 4595
1. Steven, are TagsChanging and TagsChanged events sent to plugins if 'Love' (and other database-only) field is changed?
2. Could some event be fired if track properties (eg. 'Track Gain') are changed?
3. No rating should be no value, but it seems that API returns 0 for no rating.
Last Edit: April 17, 2013, 05:28:15 AM by boroda74

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
1. having a look at the code no its not - i am ok with adding the tag events for that
2. if i make it a general file properties event then its a lot of places affected so can you be specific about what you want it for
3. i havent checked but if true when i look at this i will change it to -1 (but i am surprised thats not already the case)

i will try and look at this on the weekend

boroda

  • Sr. Member
  • ****
  • Posts: 4595
1. Please do so.
2. Currently I need it only for ReplayGainTrack and ReplayGainAlbum properties, but I think it would be useful also for LastPlayed, PlayCount and SkipCount properties.
3. OK

Thank you.

Last Edit: April 17, 2013, 08:11:22 PM by boroda74

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
I have a few questions:

1. Is it possible to provide more information on failed startup? My lyrics plugin has fails to enable every second time I disable and reenable it. The whole Initialise() has a try-catch block, but this still happens and I don't see why.

2. Are these *.config files required? my lyrics plugin kept crashing MusicBee without it.

3. Is there a documentation somewhere? it took my quite long to figure out that the mb_ in the name is required

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
for 1 i guess that could be a MB bug but i would need your plugin to see whats going on
for 2, i dont think the file is essential as it tells the .NET environment which version to use but i think it can work it out itself. You should be using .NET4 client profile in your build settings. I have no idea why it would crash MB unless you were not using the .NET4 client profile build
for 3, only what you see in the notes on the forum topic and comments in the example program

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
1. You can see my Code on GitHub: https://github.com/quickwango/LyricsReloaded

2. My fail, I used MB2 instead of MB2.1

3. This makes it quite hard to develop plugins. And the fact that we can't easily debug MusicBee itself makes it even harder.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
2. My fail, I used MB2 instead of MB2.1
i looks like you have an up-to-date MusicBeeInterface file but using the old method for loading the interface (i expect because thats how the old lyrics plugin did it). See the example file included with the download
replace:
                this.musicBee = (MusicBeeApiInterface)Marshal.PtrToStructure(apiPtr, typeof(MusicBeeApiInterface));
with:
            this.musicBee = new MusicBeeApiInterface();
            this.musicBee.Initialise(apiPtr);

that way it will not crash if you are using MB 2.0

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.
you should also call:
mbApiInterface.Setting_GetPersistentStoragePath()
to get the path for writing any settings/ working files.
Last Edit: June 19, 2013, 07:46:12 PM by Steven

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
That was correct, however I didn't take the line from the Lyrics plugin^^ Seems like there are more plugins doing it wrong...

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
i just added to the previous post in case you havent seen it.
Also as long as the interface definition file is an old one, it wont matter if the old initialisation method is used - it only matters if you are using a newer definition file

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
But I'm not writing any files, just loading files a user might have placed in the sub directory.

Where is that persistent storage path going?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
i didnt look at your code closely so if you are reading a file only then thats fine.
If you are writing to files, the settings path will be same as for all musicbee settings related files and will depend on whether the user configures musicbee for portable mode - if not then the default windows application settings path is used

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
These files are extensions to the plugin, so I think the location is appropriate.

What versions should I set to support 2.0?

also: have you seen http://getmusicbee.com/forum/index.php?topic=9971.0 ? that would make this easier^^

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
Its only necessary to use a newer interface file if you need access to new functions which i dont think you do - any API interface updates are backwards compatible.
If you are to use the newer interface definition file and want the plugin to also work with MB 2.0, change:
            about.MinInterfaceVersion = MinInterfaceVersion;
            about.MinApiRevision = MinApiRevision;
to
            about.MinInterfaceVersion = 20;
            about.MinApiRevision = 25;

quick_wango

  • Jr. Member
  • **
  • Posts: 108
  • Software Engineer
You're suggestions broke the plugin. init() is not called anymore, so it seems like ReceiveNotification() is not being called

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34349
the only reason i can think of is the plugin is disabled in the preferences