Author Topic: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc  (Read 76015 times)

zorexx

  • Jr. Member
  • **
  • Posts: 36
MusicBeeIPC

Wiki page:
http://musicbee.wikia.com/wiki/MusicBeeIPC

Latest version: 2.0.0

Highlights for this release (2.0):
-A bunch of new functions, and some helper functions
-Search and jump functions!
-Play and pause functions are now "built-in" to the plugin rather than the SDK
-4 new SDKs (AutoIt, Python, Ruby, and Java)
-Window functions (minimize, maximize, bring to front, etc)

Description:
Control MusicBee without using the plugin interface, with various programming/scripting languages.
SDKs are provided for C++, C#, Java, Python, Ruby, AutoHotkey, and AutoIt.

Installation:
Copy the MusicBeeIPC.dll into your MusicBee Plugins folder. (Usually located at C:\Program Files (x86)\MusicBee\Plugins)

License: GNU GPLv3

SDK License: BSD 2-Clause License


Downloads:
Plugin:
https://kerlilow.me/files/downloads/MusicBeeIPC.zip

Source:
https://kerlilow.me/files/downloads/MusicBeeIPC_src.zip

SDK:
C++:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cpp.zip
C#:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cs.zip
Java:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_java.zip
Python:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_py.zip
Ruby:
gem install musicbeeipc
Perl:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_pl.zip
AutoHotkey:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_ahk.zip
AutoIt:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_au3.zip

SDK samples:
C++:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cpp_sample.zip
C#:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cs_sample.zip
Java:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_java_sample.zip
Python:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_py_sample.zip
Ruby:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_rb_sample.zip
Perl:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_pl_sample.zip
AutoHotkey:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_ahk_sample.zip
AutoIt:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_au3_sample.zip

SDK source:
C++:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cpp_src.zip
C#:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_cs_src.zip
Java:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_java_src.zip
Python:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_py_src.zip
Ruby:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_rb_src.zip
Perl:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_pl_src.zip
AutoHotkey:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_ahk_src.zip
AutoIt:
https://kerlilow.me/files/downloads/MusicBeeIPCSDK_au3_src.zip


Enjoy!
Last Edit: February 28, 2017, 02:57:48 PM by zorexx

mrad

  • Guest
Scalable awesomeness :) 10/10



Thanks Zorexx.

Last Edit: December 16, 2013, 07:37:49 PM by mrad

zorexx

  • Jr. Member
  • **
  • Posts: 36
I've added the Library_Query functions now so you can now get the selected files like this:

Code: AutoHotkey
MB_QueryFiles("domain=SelectedFiles")

and then call

Code: AutoHotkey
MB_QueryGetNextFile()

to get the files, just keep calling that function until it returns an empty string to get all selected files.
QueryGetAllFiles doesn't seem to work very well, maybe because the files are separated by null character? Not too sure, have not looked too much into it since it's already 3AM here >.<

mrad

  • Guest
Strange, the following always returns 2 ...

Quote
    item := MB_QueryFiles("domain=SelectedFiles")
    Loop
    {
        if !item
            break

        MsgBox,, Music Bee, %item%
        item := MB_QueryGetNextFile()
    }

zorexx

  • Jr. Member
  • **
  • Posts: 36
You need to replace the mb_IPC.dll since the previous one does not have the Query functions

mrad

  • Guest
I think I had MB loaded when trying to replace the dll and didn't notice that the dll had not been replaced, thanks.

I see the MB_QueryFiles("domain=SelectedFiles") call returns path and filenames.

I wonder if any API calls can return the MB indexed item numbers and MB_GetFileProperty(MBFP_xxx) etc. can be utilised on each.

The MB listview indices of selected items will probably be a bridge too far to cross.

zorexx

  • Jr. Member
  • **
  • Posts: 36
I was looking on that as well but apparently there isn't any link between Query and index.
There is, however, some functions to retrieve the info of the files based on the file url and modify them as well.
These functions will be included in the next release (v1.1.0, scheduled 15/1/2014).
So until it is released, you will have to use some alternative methods.
The release will include about 56 new functions (many of which takes in more than 1 input, which is why implementing them isn't as straightforward to implement as the functions currently available), which is why it's going to take some time (also because I will be very busy again for the coming 2 weeks  :().

**Edit**
Created a wiki page for the plugin:
http://musicbee.wikia.com/wiki/MusicBeeIPC
Last Edit: December 18, 2013, 12:07:05 PM by zorexx

Anaerin

  • Guest
Out of interest, should I be seeing the "MBMLForm" window? And I know it's from this plugin, 'cause when I close it the IPC pipe stops working. :) I believe IPC still works if a window is hidden...

zorexx

  • Jr. Member
  • **
  • Posts: 36
Very sorry for the late reply. Have been really busy since the beginning of the year (thus the delay of the release of the next version, but rest assured, it's being worked on and it's almost complete). The last time I checked the forums was probably a month ago.  :(

As for your question, you shouldn't be seeing the MBMLForm window, it's supposed to be hidden. May I know what version of Windows you're running on?

Also, does the MBML Form starts minimized?
Last Edit: March 21, 2014, 01:51:11 PM by zorexx

zorexx

  • Jr. Member
  • **
  • Posts: 36
Finally, after so many months of delay, v2 is officially released!

First, I would like to apologize for the delay, it has been a really busy year for me and I only get to work on this project a few days each month.

Due to the huge amount of changes, I've decided to release it as v2.0 instead of v1.1.
This version is not backwards-compatible with v1.  :(

v2 implements almost all the functions provided by the plugin interface. I've picked some out after deciding that they are not suitable to be implemented in this plugin, and it's better if you just write your own plugin if you were going to use those functions.
Despite saying that, all suggestions are welcome.  :)

In v1, WM_COPYDATA was used to transfer larger data (data larger than the size of an integer, which is 4 bytes) from the plugin to the external program. As a result, the external program has to have a window message listener (in most cases, a hidden window) to be able to receive larger data. This will cause limitations and difficulties to implement it in many languages, especially scripting languages which does not have a message listener interface or anything similar. And also, the implementation is not very elegant.
To solve this problem, v2 uses memory mapped file to transfer data from the plugin to the external program. So as long as the language has a dll interface, an SDK can be made for it. Also, memory mapped files are much more efficient at transferring large data than WM_COPYDATA.
(Note: WM_COPYDATA is still used to transfer data from the external program to the plugin).

Also, the SDKs no longer have 2 variants (regular and instant) anymore.
Starting from v2, all releases will be equivalent to the instant variant in v1.

Note: The MBMLForm window is removed in v2, so anybody who had problems with it, it should not show up anymore.  ;)

Highlights for this release (2.0):
-A bunch of new functions, and some helper functions
-Search and jump functions!
-Play and pause functions are now "built-in" to the plugin rather than the SDK
-4 new SDKs (AutoIt, Python, Ruby, and Java)
-Window functions (minimize, maximize, bring to front, etc)

Hope you enjoy the new version!
Last Edit: March 30, 2014, 10:21:11 AM by zorexx

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
one minor thing is enums is missing Virtual10 to Virtual16 (135..141) and Custom10 to Custom16 (128..134)
also if you want to detect MB v2.4 for future reference, its ApiRevision 39+

its quite impressive the number of functions you are supporting
Last Edit: March 30, 2014, 10:33:59 AM by Steven

zorexx

  • Jr. Member
  • **
  • Posts: 36
Thanks for notifying, I guess I was using the old plugin api for the enums when I was programming it and left out some updates.  :-X
Shall do some ninja updates.  ;D

As for the v2.4, so I'll just add ApiRevision <= 38? or <= 39?
Will there be an api update following the release of MB v2.4?
If there will be, I'll just wait for the api update and update everything I'll need to in one go.

Edit: Also found that the following are also missing:
Artists = 144,
ArtistsWithArtistRole = 145,
ArtistsWithPerformerRole = 146,
ArtistsWithGuestRole = 147,
ArtistsWithRemixerRole = 148,
Genres = 143,
Last Edit: March 30, 2014, 11:13:59 AM by zorexx

boroda

  • Sr. Member
  • ****
  • Posts: 4595
As for the v2.4, so I'll just add ApiRevision <= 38? or <= 39?
"minApiRevision = 39" in the "about" structure

zorexx

  • Jr. Member
  • **
  • Posts: 36
Ninja update complete, reported missing enums added.  ;D

"minApiRevision = 39" in the "about" structure
Doesn't the MinApiRevision in the about structure refers to the required MusicBee version?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
Doesn't the MinApiRevision in the about structure refers to the required MusicBee version?
Yes. But your plugin requires latest MB version?