Controlling mm5 via com object from external vb code/vbscript

To discuss development of addons / skins / customization of MediaMonkey v5 / v2024

Moderators: jiri, drakinite, Addon Administrators

alex11110001
Posts: 2
Joined: Wed Apr 09, 2025 2:42 am

Controlling mm5 via com object from external vb code/vbscript

Post by alex11110001 »

The idea is simple: if mm is running, switch to the next track. I'm having a problem with the "mm is running" part. First, GetObject doesn't seem to work at all. This line throws "ActiveX component can't create object" runtime error:

Code: Select all

Set mm = GetObject(, "SongsDB5.SDBApplication")
Therefore I can't use it to check if mm is running - I have to call CreateObject regardless of whether mm is running or not. There's another problem - if the app is not running, calling CreateObject launches the app, but then the com interface stops working. Finally, there's SDBApplication.IsRunning flag, but it's always True for some reason.

Code: Select all

Dim mm
Set mm = CreateObject("SongsDB5.SDBApplication")  ' launches the mm
Debug.Print mm.IsRunning  ' prints True immediately, not even waiting for the mm to finish loading
mm.Player.Next  ' doesn't switch to the next track; sometimes no visible error, sometimes it's "Access violation at address..." in the mm
And if I leave the mm open and try running the code above the second time, vb throws a runtime error "Server execution failed" on CreateObject call. Oh, and if mm was launched normally (via double-clicking on a shortcut, for example), then the script works perfectly.

So, is it me or it's an mm's issue? What the right way or maybe a workaround?
Ludek
Posts: 5100
Joined: Fri Mar 09, 2007 9:00 am

Re: Controlling mm5 via com object from external vb code/vbscript

Post by Ludek »

Hi, a cross-platform way of controlling MM5 from external applications is via the Chrome Devtools API. You can find an explanation on how to use it with MediaMonkey here: viewtopic.php?p=447737#p447737
alex11110001
Posts: 2
Joined: Wed Apr 09, 2025 2:42 am

Re: Controlling mm5 via com object from external vb code/vbscript

Post by alex11110001 »

Hi,

it's all very interesting, but I'd rather use something I'm used to instead of learning a completely new toolset. There's also no need for it to be cross-platform, windows is enough.

Let me maybe rephrase the question, split it into two even. So I'm writing scripts that communicate with mm via com objects.
1. For scripts that require mm to be running, how do I check that? Can I do this using mm com objects, some other mm-specific method, or just search for MediaMonkey.exe process?
2. For scripts that are allowed to start mm if it's not yet running, before interacting with it, how do I do that? Again, is there some specific method? If not, and a script runs mm's executable, how it then knows when mm is loaded and ready to accept commands?

Thanks!
Ludek
Posts: 5100
Joined: Fri Mar 09, 2007 9:00 am

Re: Controlling mm5 via com object from external vb code/vbscript

Post by Ludek »

Reading this link

http://localhost:9222/json

to check whether MM is running and ready to accept commands is reliable method

As for checking MediaMonkey.exe process, this is not enough as MM5/2024 is based on Chromium engine and there are multiple MediaMonkeyEngine.exe processes (for rendering and network services)..

Especially the 'MediaMonkeyEngine.exe --type=renderer' is the process that needs to run for MM to be "ready"
alex11110001
Posts: 2
Joined: Wed Apr 09, 2025 2:42 am

Re: Controlling mm5 via com object from external vb code/vbscript

Post by alex11110001 »

That's useful, thank you. Though I mentioned MediaMonkey.exe, not MediaMonkeyEngine.exe, and it seems to have just one instance, at least at the moment.
Last edited by alex11110001 on Fri Apr 11, 2025 11:44 am, edited 1 time in total.
Post Reply