Page 1 of 1
MM5 Media Sharing Server Port
Posted: Mon Sep 16, 2024 4:57 am
by eshaacacia
Hi,
I have created multiple servers for Media sharing, with different names and ports.
Is there a way I can externally set which server I want to enable on when the application is launched?
For example I have two servers Server1 and Server 2. I want to run a script (C++) that launches my Monkey Media application and enables 'Server1' as the server. Currently my script launches the application and I manually change the server by going into Tools>Options>Media Sharing
Re: MM5 Media Sharing Server Port
Posted: Mon Sep 16, 2024 6:25 am
by Peke
Hi,
I think that it would be easier to create two local Portable MM installations and set them with single Server enabled, then on your wish start one or another and also you can easily close one or another with external scripts.
If you need help let me know.
Dual servers often gets blocked in Firewall and need much more configuration than just starting to MMs

If you wanty to go that way I can help you, but for now there is no API command to enable/disable MM servers.
Re: MM5 Media Sharing Server Port
Posted: Mon Sep 16, 2024 8:42 am
by eshaacacia
Hi Peke,
Thanks for that answer. Making multiple portable installs also works but then I would need to change the path to MM every time. This too is doable but not the most efficient. I don't mind doing the configuration required for dual servers if its a one time setup.
Also just to clarify, it is not just two servers but possibly more around 7-8 that I will need to configure.
If you could help me understand my options I will be able to make an informed decision about what best suits my solution.
Thanks!
Re: MM5 Media Sharing Server Port
Posted: Mon Sep 16, 2024 6:04 pm
by Peke
Hi,
Hmmm interesting, no one ever had need for more than 1-2 servers, in most cases 1 can be configured to serve both, so this is interesting use case and could benefit both MM and you as user.
What is the options and need for such number of servers? (Use PM or Ticket if you want to talk about this more privately)
Re: MM5 Media Sharing Server Port
Posted: Tue Sep 17, 2024 4:32 am
by eshaacacia
Hi Peke,
Sure! I've just sent you a PM discussing some details regarding the same. As of now the portable installs seems to do the job although a bit annoying to set up each time. Could you enlighten me on the difference between a normal and a portable install?
Re: MM5 Media Sharing Server Port
Posted: Tue Sep 17, 2024 9:11 am
by eshaacacia
Hi Peke,
Additional question. When I terminate my MM from my external script 80% of the time all four processes get terminated but 20% there is still one process running that I then have to manually end from the task manager. Could you help me debug this?
Here is the code snippet for the same:
Code: Select all
// Terminate MediaMonkey process
if (piMediaMonkey.hProcess) {
// Attempt to close the main window gracefully before terminating the process
PostMessage(hwndMediaMonkey, WM_CLOSE, 0, 0);
WaitForSingleObject(piMediaMonkey.hProcess, 5000); // Wait up to 5 seconds for the process to close
// If the process is still running, force terminate
if (WaitForSingleObject(piMediaMonkey.hProcess, 0) != WAIT_OBJECT_0) {
TerminateProcess(piMediaMonkey.hProcess, 0);
}
CloseHandle(piMediaMonkey.hProcess);
CloseHandle(piMediaMonkey.hThread);
}
Re: MM5 Media Sharing Server Port
Posted: Wed Sep 18, 2024 7:11 am
by PetrCBR
Try to make us a debuglog, please.
Re: MM5 Media Sharing Server Port
Posted: Wed Sep 18, 2024 1:23 pm
by Ludek
eshaacacia wrote: ↑Mon Sep 16, 2024 4:57 am
Hi,
I have created multiple servers for Media sharing, with different names and ports.
Is there a way I can externally set which server I want to enable on when the application is launched?
For example I have two servers Server1 and Server 2. I want to run a script (C++) that launches my Monkey Media application and enables 'Server1' as the server. Currently my script launches the application and I manually change the server by going into Tools>Options>Media Sharing
For controlling MediaMonkey from external applications see this:
https://www.mediamonkey.com/wiki/Contro ... plications
This way you can run any JS code and enable/disable or configure the servers :
https://www.mediamonkey.com/docs/api/cl ... erver.html
Re: MM5 Media Sharing Server Port
Posted: Fri Sep 20, 2024 5:17 am
by eshaacacia
Thanks for the API Ludek! For now I'm trying out with portable MM installs since I want to run multiple instances simultaneously and portable installs ensures proper isolation and concurrency management.
Currently when I run multiple portable installs of MM it works fine. But on leaving it running overnight when I try to cast to my device the next morning I get a Playback Error saying the device cannot decode the mp3 file. Do you have an idea what might be causing this?
edit: I have just noticed that from the two different instances, each from a separate portable install, each running on different servers, I can only command one device. If I try to command another device on the second instance it throws a playback error
Re: MM5 Media Sharing Server Port
Posted: Wed Sep 25, 2024 7:04 am
by EthnRift
eshaacacia wrote: ↑Fri Sep 20, 2024 5:17 am
Thanks for the API Ludek! For now I'm trying out with portable MM installs since I want to run multiple instances simultaneously and portable installs ensures proper isolation and concurrency management.
Currently when I run multiple portable installs of MM it works fine. But on leaving it running overnight when I try to cast to my device the next morning I get a Playback Error saying the device cannot decode the mp3 file. Do you have an idea what might be causing this?
edit: I have just noticed that from the two different instances, each from a separate portable install, each running on different servers, I can only command one device. If I try to command another device on the second instance it throws a playback error
Have you tried running just two instances and alternating between them more frequently, rather than leaving them running overnight? This could help determine if it's a timeout or buffering issue. Additionally, do you get the same playback error with different file types, or is it specific to MP3s? This might give a clue about the decoding capabilities of the devices.