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

zorexx

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

gustav19

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

gustav19

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

zorexx

  • Jr. Member
  • **
  • Posts: 36
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.
Last Edit: July 24, 2015, 05:19:41 AM by zorexx

snwflake

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

zorexx

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

boroda

  • Sr. Member
  • ****
  • Posts: 4622
it should work because mb versions are usually backward compatible. maybe some new functionality won't work.

snwflake

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

zorexx

  • Jr. Member
  • **
  • Posts: 36

snwflake

  • Guest
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?  ???
Last Edit: March 01, 2017, 03:19:28 PM by snwflake

boroda

  • Sr. Member
  • ****
  • Posts: 4622
i'm sure that *some* limit for tag lengths exists, but i never succeeded to accidentally reach it :)

zorexx

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

snwflake

  • Guest
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!
Last Edit: March 01, 2017, 08:17:00 PM by snwflake

Lkydiruw

  • Newbie
  • *
  • Posts: 1
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.
Last Edit: March 09, 2017, 11:01:21 PM by Lkydiruw

ArachneNet

  • Newbie
  • *
  • Posts: 13
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! :)