Page 1 of 1

Address the MM5 from an external app

Posted: Tue Oct 19, 2021 12:19 pm
by miriki
Hi, all!

(I had already written this in the German forum. But after 70 views there with no answer I thought I'll try again here ... ;-) )

Perhaps in advance of what and why I'm trying: I have a PC in the living room. This has a cable receiver (with DVBViewer Server and DVR) and external USB hard drives with videos, audios, etc. This PC is connected to a multimedia receiver (Onkyo), parallel to an X-Box and a Playstation. The receiver in turn is then connected to an LCD TV (Samsung). So I can watch TV, XB or PS on the TV. The DVB also streams its program to other clients via the network. (In addition, the server also performs other services, such as web server using WAMP, etc.)

Some time ago I played around with MediaMonkey, 4 I think, and also did a little something with the script interface in VBS. Now I've got 2 lifetime licenses and try my hand at the MM5. And I'm just wondering if desperation is an option. ;-)

In the VBS at the time I had something like that

Code: Select all

Set obj_ItemList = SDB.SelectedSongList
For i = 0 to obj_ItemList.Count - 1
    Set obj_ItemDetails = obj_ItemList.Item (i)
    str_user5 = obj_ItemDetails.Custom5
[. . . ]
The point is that I go through the entries selected in the main window and then use the details to carry out certain actions. So I was then able to use details of the entry

Code: Select all

obj_ItemDetails.Date = str_Year
change and then with

Code: Select all

obj_Itemlist.UpdateAll
update the entries in the database.

Now I'm trying something similar with MM5. However, I would now like to build a GUI (preferably in C# or VB). I mainly use MM for my videos. For example, I extracted a bunch of videos from my TV movie subscription DVDs. The file names are structured quite "cleanly" and actually always contain a "{tt ......}" in the file name with the IMDB ID. I then get further details as JSON via TMDB and would then like to write them into the DB of MM. But I'm just not getting on well.

a) When I try to set MediaMonkey as a reference for COM, Visual Studio 19 smears "quietly" away, so without an error message. That happens with VB and with C#. So I don't get this thing addressed as COM from there.

b) Inspired by MediaMonkeyNet (/mmuffins/MediaMonkeyNet on github), with which I had a brief sense of success with the sample console application, I tried to tinker a class for a GUI application. But somehow nothing works.

c) With WebSocketSharp (/sta/websocket-sharp on github) I get connected to MM, but I don't really know what to send there. So far I only get an error with the JSON element 0 or something like that.

d) The mess with JS in the PowerShell is also slowly growing like a tumor. First Visual Studio Code, then NodeJS, then Electron for the GUI. According to dir /s a ​​"hello world" now has 17,377 files in 7,073 directories. That's ill... :-(

e) A three-line VBS via cscript in the shell (here from the german forum) seems to me to be the most promising approach so far. Here is with

Code: Select all

Set SDB = CreateObject ("SongsDB5.SDBApplication")
SLText = SDB.runJSCode ("(function () {return app.db.getTracklist ('SELECT * FROM Songs', -1) .asJSON;}) ()", True)
a JSON retrieved via JS via COM. The annoying thing is that MM smears away all my nose with a runtime error (217, I think) during (incorrect) attempts and does not restart itself properly. There is always a zombie task in the system that I first have to kill via the manager. JS is really not my world, much less so than VBS. ;-)

The way I see it, I can also perform operations on the DB using executeQueryAsync and getQueryResultAsync. But here I need start-up help. Because I don't get the answer directly with .asJSON, as described above.

Who would like to help me a bit here, whether with e) or one of the other points, maybe even a completely different approach?

Michael

Re: Address the MM5 from an external app

Posted: Wed Oct 20, 2021 8:05 am
by TIV73
The problem with visual studio you mentioned is a known issue.

b and c are essentially the same thing, mediamonkeynet uses websockets to connect interact with the chromium frontend of mediamonkey via the chrome devtools protocol. An implementation is available here where it's used in a rainmeter plugin. Not exactly graphical, but it showcases how to use the library in an actual project.

Also have a look at this thread where an alternative implementation via nodejs and vb.net are discussed. There are also some references to the new upcoming api.

Re: Address the MM5 from an external app

Posted: Sun Oct 24, 2021 11:06 am
by miriki
Hi, Tiv!
TIV73 wrote: Wed Oct 20, 2021 8:05 amThe problem with visual studio you mentioned is a known issue.
Ah, ok, thank you. Any ideas about when it might get fixed?
b and c are essentially the same thing, mediamonkeynet uses websockets [ . . . ]
Yeah, sure, I was aware of that. The focus on CLI with the MediaMonkeyNet sample led me to use WebSockets, too, to create a simple framework focussing directly on GUI. Not that I wasn't able to use MediaMonkeyNet, but to get familiar a bit further using WebSockets.
interact with the chromium frontend
And somewhere at that point, where "only localhost connection" was mentioned, I kind of stopped reading (and trying with my WebSockets approach).
Also have a look at this thread
I did, in advance and multiple times. The problem with that thread, at least for me, is that I don't see a solution. It was switching back and forth, left and right, sometimes stating "it worked", but I don't see what exactly and how it worked.

Nevertheless I started with the approach of VBS sending JS commands. As said it looked as a promising approach. But I don't have a clue how to handle async results within that JS prior to return to the VBS.

Michael

Re: Address the MM5 from an external app

Posted: Tue Dec 28, 2021 5:01 pm
by scubanarc
TIV73 wrote: Wed Oct 20, 2021 8:05 am The problem with visual studio you mentioned is a known issue.
Any idea when that's going to be fixed? It's something that I'd like to use.

Re: Address the MM5 from an external app

Posted: Tue Dec 28, 2021 5:29 pm
by TIV73
Check the quoted link, it contains all currently available information.

Re: Address the MM5 from an external app

Posted: Tue Dec 28, 2021 7:39 pm
by drakinite
The target is currently for MediaMonkey 5.0.3. There are currently 207 other issues with the same target version, so I cannot promise it will not be deferred; but I have increased the priority because you guys are waiting for the fix.

Re: Address the MM5 from an external app

Posted: Tue Jan 04, 2022 6:22 pm
by Ludek
Hi,
I am not sure that I understand what's your goal exactly, but I think that the easiest way should be use the JS api. i.e. watch e.g. /scripts/swapArtistTitle/ to know how to modify track properties and if you need to do it remotelly then watch /sampleScripts/remoteControl/ that allows you to catch your http post request to MM5 (via default UPnP/DLNA) server and proceed the native JS code as you like.

Combining the old COM model (VBS) with JS code is cumbersome, wouldn't work cross-platform and probably would bring just further and further issues.

Re: Address the MM5 from an external app

Posted: Sat Jun 18, 2022 1:42 am
by bensynnock
You should try this with visual studio 2022 - I've got it working now - although there are one or two changes in functionality I'm trying to figure out.