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

EpicCyndaquil

  • Guest
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! :)

zorexx

  • Jr. Member
  • **
  • Posts: 36
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.

Antonski

  • Sr. Member
  • ****
  • Posts: 356
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.

zorexx

  • Jr. Member
  • **
  • Posts: 36
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
Last Edit: January 16, 2015, 01:42:19 AM by zorexx


EpicCyndaquil

  • Guest
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

zorexx

  • Jr. Member
  • **
  • Posts: 36
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.

EpicCyndaquil

  • Guest
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? I'd gladly contribute to it in my spare time.

Just for fun, here's a preview of what I'm working on:


It's a plugin for Wox, 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.

zorexx

  • Jr. Member
  • **
  • Posts: 36
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. ;)

zorexx

  • Jr. Member
  • **
  • Posts: 36
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)

Duke9700

  • Jr. Member
  • **
  • Posts: 22
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.

zorexx

  • Jr. Member
  • **
  • Posts: 36
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 ;)

gustav19

  • Guest
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


gustav19

  • Guest
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);