Author Topic: MusicBee API  (Read 189448 times)

boroda

  • Hero Member
  • *****
  • Posts: 3520
Steven, could you add a few options to API:

1. function to query for all selected files in current view.
2. possibility for plugins to add main menu items (i suggest that clicking on this items should send custom notifications to plugin).

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31045
for 1, thats fine
for 2, can you give a specific example you have in mind

boroda

  • Hero Member
  • *****
  • Posts: 3520
for 2, can you give a specific example you have in mind
I try to develop small plugin for coping one tag to another and for swapping 2 tags for selected files. Suppose that the only sense to use such plugin is to invoke its functions from menu/hotkey/toolbar button (mostly important is menu).  

3. Would it be possible to get user defined names (ie displayed names) for custom tags?
Last Edit: June 22, 2011, 10:26:21 PM by boroda74

Elberet

  • Full Member
  • ***
  • Posts: 167
With regard to this...
http://getmusicbee.com/forum/index.php?action=post;topic=3778.0;num_replies=2

This took me a bit by surprise... I, too, assumed that a plugin would get a TagsChanged notification whenever a file in the library had its tags altered...

I'm probably just too blind, but is there a complete documentation for the API somewhere? Such as what gets fired when, what the more obscure API calls actually do, and so on?

boroda

  • Hero Member
  • *****
  • Posts: 3520
I'm probably just too blind, but is there a complete documentation for the API somewhere? Such as what gets fired when, what the more obscure API calls actually do, and so on?
Download code examples at the beginning of this topic. Examples contain MusicBeeInterface.cs (and for other languages too) with full API, but its mostly self-documenting (using meaningful names) and almost without comments.

boroda

  • Hero Member
  • *****
  • Posts: 3520
Steven, 2 more (related to previous) requests for MB API:

1. Could you add function to query for all displayed files in current view. Of course I mean files included in currently displayed track list, not the files that are physically displayed on monitor (this may be useful if no files are selected and for plugins that do not modify files - i.e. exports some info about currently displayed tracks).

2. Could you add function to get localized tag names and file properties  (such as 'Play Count, 'Play Skip', etc.) along with function to get user defined names of custom tags?

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31045
i should be starting on the next MB version next weekend so i will look at these requests then

Elberet

  • Full Member
  • ***
  • Posts: 167
Download code examples at the beginning of this topic.
Examples are great, but this is not what I'd call documentation... besides, it should be kinda obvious that I've looked at these files before, no? :-)

e-motiv

  • Full Member
  • ***
  • Posts: 182
Is there any way the API or functions of musicbee directly can be called via COM or Dll Call or Windows PostMessage?

DLL: I checked all dll's and exe's in the musicbee folder with DLL Export viewer, but got nothing, though don't know if that is the way to be certain.
COM: Also, since people talke about .NET and I thought that .NET can always be accessed via COM, maybe that route is also a way?
Windows Postmessage: No idea where this takes effect in MB...

This has all to do with the fact that I want to do small stuff in Musicbee via Autohotkey (autohotkey.net).
(e.g. http://getmusicbee.com/forum/index.php?topic=3778.msg20512)

Now, if everything here fails, and I have to take the road of C#, I wonder:
- Is the development wiki still and forever down?
- Can anyone set me on my way with eclipse (C#)? (I have downloaded the C# file from the first post and though I work with classes a lot in other environments I am totally confused what file/class is used for what end and how to begin with even a simple "Hello World", even a simple C compiled "anything".   ::)

Thanks and don't forget, holding my hand might give the community an extra plugin developer.   ;D :P
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Elberet

  • Full Member
  • ***
  • Posts: 167
I noticed there's no API to add items to the now playing list other than play now (which replaces everything with the selected file), queue next (which inserts the file after the currently playing item but appears to be broken) and queue last (which I haven't tested yet). I'm not sure how useful this would be, and I don't have an application for this missing API myself, right now... but anyways, a few APIs to remove and insert now-playing list items by index, get the total count of now-playing items, get the index of the currently playing item and get the indices of selected items would be nice to complete the interface.


@R U Bn: As far as I know, MusicBee does not expose any COM interfaces, and I'm not aware that it's even possible to handle direct Post messages in C# (Windows' window messages are handled deep inside the Windows Forms library)...

Personally, I have the luxury of a free Visual Studio 2010 (Pro even) via the MSDNAA program, so I can't help you with setting up things in Eclipse, but if you have any concrete questions about how MusicBee interacts with your plugin DLL, I might be able to give you some pointers. (Basically, MB loads your DLL and invokes a few methods with well-known names, such as MusicBeePlugin.Plugin#Initialize. Any communication from MB to the plugin happens by MB calling these methods, and any communication from the plugin to MB happens by the plugin calling one of a bunch of delegates it received from MB via the Initialize method (if you know C, delegates are type-safe and nicely encapsulated function pointers slash trampolines). As such, MusicBee plugins are quite specialized, as far as Hello-World-type .NET programs go...)

e-motiv

  • Full Member
  • ***
  • Posts: 182
Thank you, Elberet!  Very useful!
Though the interaction explanation doesn't enable me to start programming, the distinction between "from and to" MB etc. wíll be very useful once started.  Simple really, but only once you know it.  :-)

About post messages:
I'm not aware that it's even possible to handle direct Post messages in C# (Windows' window messages are handled deep inside the Windows Forms library)...
Do you mean from my (autohotkey) side?  Since they do make it possible to send post messages to any process or window. (Dunno if they used C# or not.)
Or do you mean from MB's side (receiving them)?  Then, I guess, it's probably out of the question unles it has been explicitly built in, or?

Anybody else that can ..
1. ..complete Elberet's info, like "dll call" (or further his info around post messages, see above)?  (COM is out apparently :-(  :-) )
2. ..set me on my way with eclipse?

Thanks again..
  Developing @ e-motiv.net       --       Musicbee plugins: Speak Back - Ghost Tracks - Radio Dig

Elberet

  • Full Member
  • ***
  • Posts: 167
I was talking about MusicBee's side... Essentially, when there are any events for a window - mouse movement, key presses, you name it -, they are put into a queue. The program typically contains a loop that calls the Windows API to take an event from that queue and send it to the window's WindowProc. "Posting" a message to a window means that you put a user-defined event into that queue; eventually, the window's WindowProc will be called with that event, and if it knows how to process it, stuff happens... or it will just silently ignore your message.

Regarding Eclipse... maybe these help:
http://emonic.sourceforge.net/html/usage.html - Emonic is a C#/.NET 2.0 plugin for Eclipse, the link explains how it's set up.
http://monodevelop.com/ - Not based on Eclipse. Mono is the opensource implementation of C#/.NET, so this should work just as well with the "real" .NET CLR.
Visual Studio 2010 Express - a free version of Visual Studio. It's a bit crippled (lacks certain refactoring features, you can't manually attach the debugger to random processes, etc.), but otherwise unlimited (no restriction on code size, all .NET features available, and no limitations on how you can license or sell your code/program).

Btw:
MusicBeeInterface.cs contains all the definitions and constants used by MusicBee. (All these enums, delegates and structs are members of the MusicBeePlugin.Plugin class.)
TestCSharpDll.cs contains the rest of the class MusicBeePlugin.Plugin, notably the various well-known methods called by MusicBee to communicate with your plugin, as well as a bit of example code that illustrates how messages are sent to MusicBee and how MusicBee's notifications are handled.
Properties\AssemblyInfo.cs is auto-generated (and auto-modified) by Visual Studio and contains a bunch of attributes that define the product name, description, copyright, version etc. strings embedded into the DLL file.
Last Edit: June 29, 2011, 05:32:05 PM by Elberet

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31045
API is updated with 2 new functions to support the boroda74's tag tools plugin
            public MB_AddMenuItem(string menuPath, string hotkeyDescription, EventHandler handler);
            public Setting_GetFieldName(MetaDataType type);

but MB_AddMenuItem will only work for boroda74 - i will notify when it have made it generally handle adding menus anywhere in MB

updated musicbee.exe (or get latest weekly update when this link is dead)
http://www.mediafire.com/?moxi4503us5w4tc


Is there any way the API or functions of musicbee directly can be called via COM or Dll Call or Windows PostMessage?
for a working open source plugin example see
https://code.google.com/p/mbprocessbar/
Last Edit: June 30, 2011, 06:25:44 PM by Steven

Elberet

  • Full Member
  • ***
  • Posts: 167
Another thing: you mentioned that Library_GetFileProperty only works on files in the library, but NowPlaying_GetFileProperty works on the currently playing file regardless whether it's in the library or not. So for any other files in the Now Playing list that aren't yet in the library, it's not possible to get the properties?

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 31045
you can get non-library files using:
NowPlaying_GetFileTag
NowPlayingList_QueryFiles then calling Library_GetFileTag
Playlist_QueryFiles then calling Library_GetFileTag
however i see i put a block on Library_GetFileTag which i have just removed, so for the next update it should work