getmusicbee.com

MusicBee & Add-Ons => Customizations => Plugins => Topic started by: zorexx on December 16, 2013, 12:32:04 PM

Title: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on December 16, 2013, 12:32:04 PM
MusicBeeIPC

Wiki page:
http://musicbee.wikia.com/wiki/MusicBeeIPC (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 (https://kerlilow.me/files/downloads/MusicBeeIPC.zip)

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

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

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

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


Enjoy!
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: mrad on December 16, 2013, 01:10:25 PM
Scalable awesomeness :) 10/10

(http://i.imgur.com/Oz3QfAa.gif)

Thanks Zorexx.

Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: zorexx on December 16, 2013, 07:05:14 PM
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 >.<
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: mrad on December 16, 2013, 07:49:44 PM
Strange, the following always returns 2 ...

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

        MsgBox,, Music Bee, %item%
        item := MB_QueryGetNextFile()
    }
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: zorexx on December 17, 2013, 02:47:22 AM
You need to replace the mb_IPC.dll since the previous one does not have the Query functions
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: mrad on December 17, 2013, 05:03:48 AM
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.
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: zorexx on December 17, 2013, 05:09:45 AM
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 (http://musicbee.wikia.com/wiki/MusicBeeIPC)
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: Anaerin on March 08, 2014, 07:11:24 PM
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...
Title: Re: MusicBeeIPC - Control MusicBee externally
Post by: zorexx on March 21, 2014, 01:47:08 PM
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?
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 30, 2014, 04:41:11 AM
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!
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Steven on March 30, 2014, 10:27:29 AM
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
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 30, 2014, 11:03:48 AM
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,
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on March 30, 2014, 11:40:01 AM
As for the v2.4, so I'll just add ApiRevision <= 38? or <= 39?
"minApiRevision = 39" in the "about" structure
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 30, 2014, 12:01:36 PM
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?
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on March 30, 2014, 12:06:53 PM
Doesn't the MinApiRevision in the about structure refers to the required MusicBee version?
Yes. But your plugin requires latest MB version?
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 30, 2014, 12:18:25 PM
It requires MB v2.3, or API revision 33 to be precise, because some of the implemented functions/enums are only available in that version. It should work just fine in future versions.

Maybe Steven was referring to the GetMusicBeeVersion function of my plugin? Since the current API only have enum up to v2.3, which means when the new MB v2.4 comes out, my plugin will detect it as v2.3.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Steven on March 30, 2014, 12:47:25 PM
yes that is what i was refering to
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 30, 2014, 01:00:04 PM
Ok, if that's the case, I will wait until the next API update so that I can do any other necessary updates in one go.
Thanks for the suggestion.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: nosaj72 on April 18, 2014, 09:52:37 PM
Great plugin. I'm using this to write a quick app to copy my ratings and playcounts between MB and iTunes.

Quick question: I can read the play counts with Library_GetFileProperty, but I can't figure out if there is a function to update them with. I see Library_SetFileTag, but no Library_SetFileProperty. Is there something I'm missing, or is this just not possible?
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on April 19, 2014, 09:59:59 AM
Thanks for the feedback.

As far as I am aware of, the values returned by GetFileProperty are read-only values so you cannot modify them.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Steven on April 19, 2014, 10:11:45 AM
Rating isnt a property - you should be able to read and set it using the ...FileTag() functions
it should be scaled on a "0".."100" scale but "0".."5" is also supported and automatically scaled to 0..100, or blank to unrate
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on April 19, 2014, 11:19:15 AM
Use Library_SetFileTag with type casting.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Diedrict on April 25, 2014, 02:25:33 PM
hello

1) is a way to enumerate DSP enabled (MB_GetDspEnabled() and MB_SetDspEnabled() are boolean only)
ex. "mono"

2) does exist a API call for "balance" state
ex. -100 to +100

greetings
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on April 25, 2014, 02:45:11 PM
Quote
1) is a way to enumerate DSP enabled (MB_GetDspEnabled() and MB_SetDspEnabled() are boolean only)
ex. "mono"

I don't think there is a way to do that since the only dsp-related functions I can find in the plugin api are MB_GetDspEnabled() and MB_SetDspEnabled().
Maybe someone who is familiar with dsp in MusicBee might be able to help you, or Steven.

Quote
2) does exist a API call for "balance" state
ex. -100 to +100

As far as I am aware of, there is no api call for that.
(Can you actually adjust the balance from MusicBee? I can't seem to find the slider for that, I was actually looking for it some time ago)

Sorry that I couldn't be much of help.  :(
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Diedrict on April 25, 2014, 03:47:44 PM
ok, then the only way to get result is --

Code
if exists mb_process 
   store MB_GetPlayState()
   close mb app
endif
load_file appdata/MusicBeeSettings.ini to buffer
change xml node <PlayerStereoBalance>0</PlayerStereoBalance> (this is a eq window setting)
change xml node <PlayerDspState></PlayerDspState> (DSP states)
change xml node <PlayerManualEqualiser></PlayerManualEqualiser> (the eq preset name and freq settings)
save_file appdata/MusicBeeSettings.ini
load mb app
if exist last PlayState
   restore PlayState
endif

is a solution until core improvement exist

i wonder if way exist to reload setting file while mb loaded

greetings
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on April 25, 2014, 06:00:55 PM
Oh, I see the balance slider now.
And I get what you mean now, about enabling the DSP.
The SetDspEnabled works exactly like the Controls > DSP Effects menu item, and I can't seem to find a function to enable individual effects in the plugin interface either. :(

As for reloading the settings file while mb is running, you might have to ask Steven about this. He might read this topic and hopefully give you an answer, but I'm afraid I am not aware of any ways to reload the settings file while mb is running.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: psychoadept on May 03, 2014, 05:24:36 PM
Please be sure to add your plugin to the wiki.  I imagine it will be helpful to many people.

http://musicbee.wikia.com/wiki/Plugins
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on May 03, 2014, 05:31:11 PM
Please be sure to add your plugin to the wiki.  I imagine it will be helpful to many people.

http://musicbee.wikia.com/wiki/Plugins

Thanks, but I'm pretty sure it's already on the wiki, as stated on the first post.  :)

http://musicbee.wikia.com/wiki/MusicBeeIPC (http://musicbee.wikia.com/wiki/MusicBeeIPC)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: psychoadept on May 03, 2014, 08:16:04 PM
Thanks, but I'm pretty sure it's already on the wiki, as stated on the first post.  :)

You're right, sorry!  I did a quick search for it on the wiki but I didn't read your original post closely.  Thanks for taking care of it!
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on May 04, 2014, 12:02:05 AM
Thanks, but I'm pretty sure it's already on the wiki, as stated on the first post.  :)

You're right, sorry!  I did a quick search for it on the wiki but I didn't read your original post closely.  Thanks for taking care of it!

No problem.  ;)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: EpicCyndaquil on August 31, 2014, 07:31:44 AM
Hey zorrexx,

Is there any way to toggle upmixing to 5.1 with this plugin? I'm not sure if that's even available in the base Musicbee API itself. (If it isn't, I'd imagine Steven would be able to implement it eventually.) This is something I'd need to do via python, so I'm counting on you! :)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on August 31, 2014, 07:57:48 AM
If the function doesn't exist in the MusicBee API then I can't implement it in this plugin.
I've checked the API I have but I don't seem to see such function, unless there's a later version that I'm not aware of.
I guess we'll have to wait until Steven includes this in the API.

The closest I can get to is to:
1. Close MusicBee

2. Edit the %APPDATA%\MusicBee\MusicBeeSettings.ini file:
Change the value of PlayerUpmixChannelCount to 6 to enable upmixing and 0 to disable upmixing.

3. Rerun MusicBee

This can be done with just python, albeit a little hacky.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Antonski on November 03, 2014, 10:30:04 PM
Hi,
How difficult would be to add a Perl support?
I don't know if I personally will write something useful, but for sure Perl is a very popular language and there will be (many?) supporters.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on November 05, 2014, 10:32:17 AM
Thanks for the suggestion.
I can do that, but I don't have the time for it this month, so you might have to wait until end of December before you can use it
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Antonski on November 06, 2014, 06:06:47 PM
No problem :)
Thanks!
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: EpicCyndaquil on February 09, 2015, 03:41:11 AM
Are you still supporting this, zorexx? I can't figure out how to make library_get_file_property work in Python - I'm getting the following error:
struct.error: cannot convert argument to integer
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on February 09, 2015, 04:03:05 AM
Yes, I am still supporting this.

I just tried the library_get_file_property and it seems to work for me.
You have to call
Code
library_get_file_property(file_url, file_property)

where
file_url is the full path to the file and
file property is one of the following constants (found in enums.py under # MBFileProperty):
Code
MBFP_Url
MBFP_Kind
MBFP_Format
MBFP_Size
MBFP_Channels
MBFP_SampleRate
MBFP_Bitrate
MBFP_DateModified
MBFP_DateAdded
MBFP_LastPlayed
MBFP_PlayCount
MBFP_SkipCount
MBFP_Duration
MBFP_NowPlayingListIndex
MBFP_ReplayGainTrack
MBFP_ReplayGainAlbum

If it still doesn't work, please show me the line where you called this function.


p/s: A little update on the Perl version:
Unfortunately, I hadn't got much time to work on it so there isn't a lot of progress so far, but I will start working on it again soon, hopefully releasing it within March.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: EpicCyndaquil on February 09, 2015, 04:55:03 AM
Awesome! I'm glad to see you're still around. Is it possible we could set up documentation for this somewhere? Perhaps something like this documentation for Wox plugins (http://doc.getwox.com/en/plugin/python_plugin.html)? I'd gladly contribute to it in my spare time.

Just for fun, here's a preview of what I'm working on:
(http://i.imgur.com/2Q03OAm.png)

It's a plugin for Wox (https://www.getwox.com/), a launcher similar to launchy (but actually maintained!) that lets you play tracks or queue tracks to play next ("add"). I'm still working on the best way to play/add artists and albums (providing a list of those that adds all tracks to the playlist) - any feedback or ideas on that would be appreciated, but certainly not required.  :)

I really appreciate your work on this API - even in its current state, it has an incredible range of features.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on February 09, 2015, 01:33:08 PM
Thanks for your feedback. I'm glad you find it useful.
What you're doing there looks great too, very similar to what I'm doing with AutoHotkey and MusicBeeIPC. Except without that beautiful interface. ;)

Regarding the documentation, I have thought of making one as well. In fact, I have included the documentation inside the source code of few of the languages to be generated by some document generators. (e.g. Python).

The reason why MusicBeeIPC still doesn't have a proper documentation is because:
1. MusicBeeIPC is coded in many languages, so keeping the documentation uniform and easy to maintain is difficult.
2. MusicBeeIPC is basically just the MusicBee plugin API brought available to external programs, and unfortunately, the MusicBee plugin API doesn't have a proper documentation as well (as far as I know, if there is one that I am not aware of, please enlighten me). Hence, there are some functions that I am not too sure what does it do or how does it work, but I have ported them anyway. Writing documentation for these functions either need a lot clarification from Steven or providing assumptions.

With that said, I will try to find a way to produce a good documentation for this.
What I have in mind is:
1. Do not use document generators, and create a single documentation containing codes for all languages but with the same explanation. (something like what's being done in MSDN)

Either way, I will have to find the time to do that, and even when I have time, porting it to Perl comes first. ;)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on February 25, 2015, 11:20:54 AM
MusicBeeIPC SDK for Perl is finally completed.

Note:
Sorry but, there is no CPAN or PPM distributions because after trying to package them for CPAN (or PPM), I came to a conclusion that it is too much of a hassle for such a small project. Hence, I've wrote my own install script, all you have to do is run (in the downloaded SDK directory):
Code
perl install.pl
and you're good to go.

Note for Python and Ruby SDK:
I found a minor spelling mistake in the Python and Ruby SDKs, change Equalizer to Equaliser if you run into any relevant problems.

Some news:
I am planning on a new version of MusicBeeIPC (v3.0?). It will use sockets instead of memory-mapped files and window messages. This should increase the portability and versatility of the SDKs, and also make porting to other languages much easier.
Aside from making things easier, using sockets allow me to easily add remote support, which I plan to. With this, you will be able to control MusicBee from a remote device or location such as your smartphone.
Since I'm adding remote support anyway, I am also thinking of adding a web interface and if possible a mobile interface, but I cannot promise these as I have no experience in these fields yet.
Needless to say, I will also add support for more languages (e.g. Visual Basic).
With that said, in the next version, MusicBeeIPC will be more than just IPC, so I am considering renaming the plugin as well.
Any feature requests or name suggestions are very welcome as this might be the biggest update for MusicBeeIPC since its first release. 8)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Duke9700 on March 27, 2015, 09:05:32 PM
First of all I LOVE this plugin. It's a much quicker and easier way to get a project going compared to the official plugin based API.

I was wondering if I'm just missing it or if MusicBeeIPC has a SetFileTag to go along with the GetFileTag command? I'm just started to delve into the API so I realize if it's not exposed in the official API it wouldn't be here but being able to write to tags would be a very convenient feature for me.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 28, 2015, 03:27:00 AM
You can do that by
f = GetFileUrl()
Library_SetFileTag(f, tag, value)
Library_CommitTagsToFile(f)

Maybe I'll throw in a helper function in the next release ;)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: gustav19 on July 22, 2015, 07:26:05 PM
You can do that by
f = GetFileUrl()
Library_SetFileTag(f, tag, value)
Library_CommitTagsToFile(f)

Maybe I'll throw in a helper function in the next release ;)

Could someone help me please?

I'm trying to edit and commit tags to a file with these methods, but it's not working. The library_SetFileTag method only takes two parameters: the file URL and a MetaData constant which indicates  the field that's being edited. Where should I put the value for the field? Trying to stick it into the third parameter gives an invalid parameters exception.

Thanks in advance
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on July 23, 2015, 08:27:24 AM
May I know which language are you using?
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: gustav19 on July 23, 2015, 11:23:54 PM
I'm using java. Here's an example of what I'm trying to do:

MusicBeeIPC mbIPC = new MusicBeeIPC();

String key = mbIPC.getFileUrl();
String value = mbIPC.getFileTag(MetaData.Keywords);
value += ", new_keyword";

mbIPC.library_setFileTag(key, MetaData.Keywords, value); //this line will give an error due to the argument 'value'
mbIPC. library_commitTagsToFile(key);
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on July 24, 2015, 12:30:58 AM
Ahh, yes. My bad, it seems like I left out the 3rd parameter for that function in the java version. I'll get it fixed asap.

Meanwhile, if you don't mind recompiling it, try applying this simple fix:
In MusicBeeIPC.java, change:
Code
    public MBError library_setFileTag(String fileUrl, MetaData field)
    {
        return MBError.fromRepr(sendMessage(WM_COPYDATA, Command.Librapry_SetFileTag, pack(fileUrl, field.getRepr())));
    }

To:
Code
    public MBError library_setFileTag(String fileUrl, MetaData field, String value)
    {
        return MBError.fromRepr(sendMessage(WM_COPYDATA, Command.Librapry_SetFileTag, pack(fileUrl, field.getRepr(), value)));
    }

Note: I haven't tested this.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: gustav19 on July 24, 2015, 01:38:04 AM
I'm sorry, it didn't work =/ it gave out no erros, but it wrote the file URL to the tag instead of the value, which was kinda funny because my song ended up being played by some weird artist called "C:\Musik\Library\Cheap Trick\Busted.mp3"
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: gustav19 on July 24, 2015, 01:53:08 AM
Hey, I got it working =D just had to make the following substitution in the method "static Pointer pack(String string_1, int int32_1, String string_2)" of the file Pack.java:

before:
bytes_2 = string_1.getBytes("UTF-16LE");

after:
bytes_2 = string_2.getBytes("UTF-16LE");
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on July 24, 2015, 02:01:11 AM
Seems like there's a typo in Pack.java as well, on line 403, change
bytes_2 = string_1...
To
bytes_2 = string_2...

Sorry for the inconvenience.

Edit: Didn't notice the last reply, glad to see you got it working. Good luck on whatever you're working on.  ;)

Edit: Fix applied.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: snwflake on February 26, 2017, 03:24:49 AM
Sorry for digging this threat out.
I just came across MusicBee. I was wondering if this SDK is also available for version ^3.*
and if there is still a resource to obtain the code from?

If not, is there something similar for version 3+ ?
I would love using the WoX Plugin EpicCyndaquil was working on.

cheers
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on February 28, 2017, 03:05:51 PM
Sorry for the late reply.

I haven't been working on MusicBeeIPC because I haven't been using MusicBee for some time now since I've moved to Linux. Too bad MusicBee isn't available on Linux :( , it's still the best player I've used.

Anyway, I've uploaded the files to my new website and fixed the links on the first post to point there.
However, the last time I tested them was when MusicBee was still on v2, so I can't be sure if it will still work on v3.
Try and see if it works.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on February 28, 2017, 03:55:09 PM
it should work because mb versions are usually backward compatible. maybe some new functionality won't work.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: snwflake on March 01, 2017, 03:09:57 AM
Thank you very much!
Even if its not working, I'll figure it out somehow.

Anything is better then building the entire thing on my own ^_^

Cheers
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 01, 2017, 05:24:59 AM
Let me know if it doesn't work and I'll try to fix it. :)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: snwflake on March 01, 2017, 03:11:19 PM
Well, still works like a charm!  :-*

May I ask what made you use window msgs instead of sockets? Didn't actually thought about juggling hWnds around.
Probably because I'm coming from unix and Xlib is a mature pain in the butt... who knows ¯\_(ツ)_/¯

The only thing driving me nuts are the return values of

Code
Library_GetArtworkUrl  // which leaves me with a path to a *.tmp file
and

Code
Library_GetArtwork // (which, I know, is deprecated) drops a base64 encoded image (at least looks like a base64 string)

Probably because all the covers are embedded into my music files? idk  :o
Somebody got a clue on how to obtain something image-ish?

The last way would be to cycle through all the albums, grab the base64-img, decode it to some path, add an id and use the id to tag the album... mhm...
I'm open for any suggestion with that  ;D

Last but not least,
great job on the IPC and also to the devs of MusicBee (even if its lacking docs  :P )

cheers!

Edit: It is indeed a base64 encoded image. So basically decode->rename->tag album would do the trick

Edit2: Is there a char-limit on Tags?  ???
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on March 01, 2017, 03:43:54 PM
i'm sure that *some* limit for tag lengths exists, but i never succeeded to accidentally reach it :)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: zorexx on March 01, 2017, 04:52:07 PM
Good to know it still works!

May I ask what made you use window msgs instead of sockets? Didn't actually thought about juggling hWnds around.

Couple of reasons, albeit not very good ones:
1. This library was primarily influenced by the ability to control Winamp via Window Messages.
2. Window Messages are easier to work with, to some extent

In hindsight, especially after porting it to so many other languages, I agree it wasn't a great choice. :-\

For that exact reason, I've been thinking of writing the next version from scratch, this time using, probably using protobuf via REST or gRPC or both.
I'm thinking of making something more universal and generalized, so that it works cross-platform.

The only thing driving me nuts are the return values of

Code
Library_GetArtworkUrl  // which leaves me with a path to a *.tmp file
and

Code
Library_GetArtwork // (which, I know, is deprecated) drops a base64 encoded image (at least looks like a base64 string)

Probably because all the covers are embedded into my music files? idk  :o
Somebody got a clue on how to obtain something image-ish?

I can't remember what it returns, but looking at the source code, all it does on the IPC side is call Library_GetArtworkUrl from the MusicBee plugin API.
Looking at the latest plugin API, there is a function called Library_GetArtworkEx (since api version 47):
Code
bool Library_GetArtworkExDelegate(string sourceFileUrl, int index, bool retrievePictureData, ref PictureLocations pictureLocations, ref string pictureUrl, ref byte[] imageData);

This should do what you want, but unfortunately MusicBeeIPC is not updated for some time and doesn't support that function. (At the date of this writing, MusicBeeIPC only supports up to api version 33 :( )

I will take a look again soon at MusicBeeIPC's source code and see if I could update MusicBeeIPC to catch up with the latest plugin API. (Or if I should just get started working on the next revamped version)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: snwflake on March 01, 2017, 05:28:26 PM
Saw that in the API and would've implemented it myself, if I knew what params to pass.

(EDIT)

Well....I'm definately too tired to code....totally missed that the last 3 params are passed by ref -.-'
Good morning!

Won't be that hard to implement then  :P  (Isn't like if there were no examples on how to handle window messages :D)

I'll get back to that tomorrow...

cheers!
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: Lkydiruw on March 09, 2017, 04:12:51 AM
Sorry if this is a really simple question, but how does one add ratings to the current track? I've tried
Code
; Rate 1 star
CapsLock & Numpad1::
    f := MB_GetFileUrl()
    MB_Library_SetFileTag(ByRef "%f%", Rating, ByRef 1)
    MB_Library_CommitTagsToFile(ByRef "%f%")
return
But that doesn't work. When I test it using
Code
f := MB_GetFileUrl()
r := MB_GetFileTag(Rating)
MsgBox Now Playing: %f%. Rating: %r%.
The rating variable is blank, so clearly i'm using the wrong field. However I have no idea what the field is meant to be called. I've also tried "RATING", "Track Rating", "RatingTrack" and "POPM", but none of them work. Any help would be appreciated. Thanks!

p.s. I'm using FLAC files, if that is relevant.

EDIT: Managed to do what I wanted using AutoHotKey's ControlSend.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: ArachneNet on May 03, 2018, 02:16:06 AM
Hi, I just found out about this plugin but unfortunately, when I tried to download the .zip file, I found out Zorexx's server no longer exists. does anyone know where I could download the files? Cheers! :)
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: snwflake on August 27, 2018, 09:50:10 AM
Hi, I just found out about this plugin but unfortunately, when I tried to download the .zip file, I found out Zorexx's server no longer exists. does anyone know where I could download the files? Cheers! :)

Links are working perfectly fine? https://kerlilow.me/files/downloads/MusicBeeIPC.zip

The wiki is just outdated, but that is always the case.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: arbor_mute on August 20, 2021, 04:15:27 AM
Link is broken ... so sad
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: phred on August 20, 2021, 01:32:18 PM
Link is broken ... so sad
You're probably out of luck as the last time the plugin developer was on the forum was March 11, 2017.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: mrbenn on August 24, 2021, 09:06:19 PM
Found a partial set of the files via Wayback Machine which I have uploaded here: https://www.mediafire.com/file/tk7ytb4hud4hta7/MusicBeeIPCrec.zip/file

It has the source, the plugin and the SDKs for Python and C++

I wasn't able to find the other SDKs etc.

Hope this helps!

Link is broken ... so sad

Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: mbdiener on September 22, 2021, 05:14:28 AM
Thanks for posting this. I had almost given up on finding a copy of the plugin. It seems to work fine on Windows 10 along with Audioband even though the plugin is around 8 years old. Thanks again!

Found a partial set of the files via Wayback Machine which I have uploaded here: https://www.mediafire.com/file/tk7ytb4hud4hta7/MusicBeeIPCrec.zip/file

It has the source, the plugin and the SDKs for Python and C++

I wasn't able to find the other SDKs etc.

Hope this helps!

Link is broken ... so sad


Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: NighTeagle on May 03, 2022, 06:49:17 PM
FYI for other users of this plugin:

I encountered an issue where this plugin prevented a correct shutdown and restart of Musicbee 3.5:
https://getmusicbee.com/forum/index.php?topic=36499.0 (https://getmusicbee.com/forum/index.php?topic=36499.0)

I have not tested whether the plugin functionality still works on MusicBee 3.5, but I doubt it given this experience.
The plugin did still work with MusicBee 3.4.

Perhaps it's related to the upgrade to .NET 4.8 of MusicBee 3.5.
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: boroda on July 31, 2023, 07:01:11 PM
i've added this plugin to add-on's section of mb site. thanks to @mrbenn for recovering lost plugin's archives!

https://getmusicbee.com/addons/plugins/486/musicbee-ipc/
Title: Re: MusicBeeIPC - Control MusicBee with Autohotkey, Python, Java, etc
Post by: BoringName on December 18, 2024, 12:49:46 AM
I've fixed this plugin so it doesn't cause the Musicbee process to lock up when switching skins.

That's all I've done, I haven't tested if everything else still works.

Link - MusicbeeIPC_Fixed.zip (https://www.mediafire.com/file/my2jscb3s9h23oj/MusicbeeIPC_Fixed.zip/file)