MM5 API with WebSockets in NodeJS

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

MyVikes
Posts: 56
Joined: Sun Jul 02, 2017 1:20 am

Re: MM5 API with WebSockets in NodeJS

Post by MyVikes »

Thanks Ludek

Where can i get additional info/documentation regarding the remoteRequest such as how to properly set the responseType? I've tried "json" and "application/json; charset=utf-8" to have the Content-Type set in the returned Headers but no luck. It's returning json text but just not recognized as such by Postman.
Ludek
Posts: 4268
Joined: Fri Mar 09, 2007 9:00 am

Re: MM5 API with WebSockets in NodeJS

Post by Ludek »

Hi, response headers settings isn't supported yet, just responseBody (as in the code example).
I'll add it to my TODO
MyVikes
Posts: 56
Joined: Sun Jul 02, 2017 1:20 am

Re: MM5 API with WebSockets in NodeJS

Post by MyVikes »

thumbs up and thanks!
Reto S.
Posts: 4
Joined: Mon Jul 05, 2021 3:45 am

Re: MM5 API with WebSockets in NodeJS

Post by Reto S. »

MyVikes wrote: Thu Jun 24, 2021 4:26 am thumbs up and thanks!
HI @MyVikes

I see you are working on a Remote Control (for yourself!?!) or do you plan to release this publicly as an App or something?
MyVikes
Posts: 56
Joined: Sun Jul 02, 2017 1:20 am

Re: MM5 API with WebSockets in NodeJS

Post by MyVikes »

TBD....i've thought about it but not sure if i want to support an app outside of my own use. :-)

i've been using it for a 1+ year and love it. except for ripping and cataloging my music collection i no longer use the MM interface.

It currently requires a VB.Net proxy communicating with the MM4 COM objects.

Primarily it allows me to quickly randomly select an album, select from n random albums (both using filters on genre, artist, etc. if desired), skip forward/backward, pause, progress to a point in the playing song, view current playlist and select a song to advance to, control MM volume and browse my library among other things. Also, it provides simple links to artist and album wiki along with a lyrics search. The song progress is a simple estimation based on the length of the song and a background timer but works fine for my use. I've thought of using an occasional ping of the server but haven't found it necessary.

I'm about 70% done migrating the VB.Net app to javascript leveraging the "app.listen(app, 'remoteRequest', (r) => {" web server recently added. So it would require just the MM5 addin javascript and then my app (Android only although i might use this as an opportunity to learn Swift). I'd written a React front end as a learning opportunity but after having it ~80% functional compared to the Android app i lost interest (:-)) and have stopped working on that.

The current performance is excellent and the MM5 javascript version thus far is comparable.

Here is a screenshot: https://www.dropbox.com/s/tqu04ewq37gtx ... 6.png?dl=0
zombiefly
Posts: 190
Joined: Fri Jun 08, 2007 3:33 pm

Re: MM5 API with WebSockets in NodeJS

Post by zombiefly »

hello,
i posted another topic re: creating a monkeybridge appliance and was wondering if any of you talented people could assist? from what i can see, this websocket work covers most of the requirement. interested to hear your thoughts please! :D

viewtopic.php?f=27&t=99672&e=1&view=unread#unread
MM5 latest [Gold] / MMA latest | OnePlus 8 PRO | Noise I make: Pushkin on Soundcloud
Image
MyVikes
Posts: 56
Joined: Sun Jul 02, 2017 1:20 am

Re: MM5 API with WebSockets in NodeJS

Post by MyVikes »

I've completed my MM5 javascript Addin leveraging the POST request Ludek added, see post here by him on Mon Jun 14, 2021 11:08 am
OK, if you have already re-written the addons for MM5 then I guess that you have already own PC app for processing the remote requests.

If you are still interesed in processing requests via the MM5 server then install build 2415 and in the /sampleScripts/ folder there is 'remoteControl' sample script.

Currently it accepts only POST requests including MMCustomRequest in the request header and valid JSON as request body.
More in the code.

The test request available at: https://reqbin.com/uw0qc1ma (adjust port based on your settings in Options > Media Sharing)
Ludek
So this doesn't use WebSockets as that was a dead end. My client is a an Android app but I'd done a React POC so anything that serves up a nothing more than a SPA app would work.

My next task it to add controls to the app/javascript Addin to redirect the output to available Chromecast device but if I understand what you're doing with a DAC bridge that would not be necessary.
Peke
Posts: 14745
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: MM5 API with WebSockets in NodeJS

Post by Peke »

Hi,
He ants that on Pi that is used as DAC bridge (MM play to multiple devices) on its 7" Display he have Remote MM5 Player controls and Metadata info. An access to Now Playing in MM5 would be a bonus.

I also upgraded his request to feature that one Device can be Controller for MM5 (Play To), list and show all control points that access MM5 over DLNA, ... and fetch Metadata for playing files. Haven't deep dived in DLNA and control point to see if you can remotely control that control point player, something for future builds.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum
Ludek
Posts: 4268
Joined: Fri Mar 09, 2007 9:00 am

Re: MM5 API with WebSockets in NodeJS

Post by Ludek »

I've completed my MM5 javascript Addin leveraging the POST request Ludek added..

So this doesn't use WebSockets as that was a dead end. My client is a an Android app but I'd done a React POC so anything that serves up a nothing more than a SPA app would work.

My next task it to add controls to the app/javascript Addin to redirect the output to available Chromecast device but if I understand what you're doing with a DAC bridge that would not be necessary.
Is your script/addon already available for testing?

As for adding another output device/list, see e.g. 'choosePlayer' in actions.js and related generateChoosePlayerSubmenu
and related code like

Code: Select all

var apl = app.sharing.getActivePlayer();
var lst = app.sharing.getAvailablePlayers();
....
app.sharing.setActivePlayerUUID( ... )
Post Reply