How can external script know when MM is actually playing

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Indi
Posts: 18
Joined: Fri May 28, 2004 5:17 pm

How can external script know when MM is actually playing

Post by Indi »

I work a lot with home automation software and have often recommended Media Monkey as a replacement for MusicMatch and WinAmp. We're often writing scripts to control things based on certain events like doorbells, motion detectors, light switches, etc., and these often involve voice response from the computer. I need to pause playback of music when the Home Automation software is speaking. Easy enough by making the MM window active and sending ^P by a script before speaking and again after speaking, but only if the music already playing. If the music isn't playing, it actually starts it up just as the computer is about to speak. If MM isn't even running, then some other program usually calls up the print window. How can an external script (ie: WSH) determine when MM is actually running and when it is playing music? Also, is there an ASCII code for the pause button on Multimedia keyboards?
jiri
Posts: 5417
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

There are two options:
- You can use WinAmp API to conrol this because MediaMonkey emulates the API in order to be able to use WinAmp plug-ins.
- You can use scripting, see the help file in this forum.

Btw, the key code is: VK_MEDIA_PLAY_PAUSE = 0xB3, but I'm afraid it won't help use as it is both for playback and for pausing.

Jiri
Indi
Posts: 18
Joined: Fri May 28, 2004 5:17 pm

Determining if music is actually playing

Post by Indi »

Thanks for the info. Using external VBS scripts, I can determine if MM is currently a running process. That solves half my battle. Can you think of a way I can determine programatically (ie, through VBS) if MM is actually playing music? Is this accomplished through the WinAmp API? That way I can determine whether or not to send the play/pause command. OR...can I somehow mute MM playback without muting all sound from the sound card (thereby, muting the speech engine, too)? Basically, I just need to find a way to keep the music from blocking other speech and alerts from the home automation program. Currently it just talks over the music making it very hard to hear. Someone has written a plug-in for the home automation software to accomplich this with WMP....but I'd much rather use Media Monkey and have recommended it as a viable alternative to a number of home automation buddies. This is kind-of the last stubborn stumbling block to cleanly interfacing it with the home automation software.

Any ideas are appreciated.
Indi
Posts: 18
Joined: Fri May 28, 2004 5:17 pm

WinAmp API "Status" flag

Post by Indi »

Well, a bit of poking around found a status flag in the WinAmpAPI. Installing WinAmpCom 2.1.1 (gen_com.dll) into the Plugins folder gives access to this and other functions. Though I'm still sorting it all out, it appears that status=0 means winamp is not playing, status=1 means that winamp is playing, status=3 means that WinAmp is paused.

Below is a VBS to determine if MediaMonkey is running. Hope this helps others out. If anyone knows how to accomplish this through the WinAmpAPI, it would much appreciated.

'IS MEDIA MONKEY RUNNING?
Set WshShell = WScript.CreateObject("WScript.Shell")
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set service = locator.ConnectServer()
Set props = service.ExecQuery("select name, description from Win32_Process where name = 'MediaMonkey.exe'")
running = props.Count
If running > 0 Then
MsgBox "MediaMonkey IS Running", 65, "Alert"
Else
'Program is not running
MsgBox "MediaMonkey is NOT running", 65, "Alert"
End If
Set WSHShell = Nothing
jiri
Posts: 5417
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

1. You got it right, the exact explanation from WinAmp SDK is: "If 'ret' is 1, Winamp is playing. If 'ret' is 3, Winamp is paused. Otherwise, playback is stopped.". You can use the same with MM.

2. A bit more friendly way for VBS is use MM automation objects in case MM is running (note that some of the properties used below are only implemented in the latest MM 2.2):

Set SDB = CreateObject( "MediaMonkey.SDBApplication")
If SDB.Player.isPlaying And Not SDB.Player.isPaused Then
'''' MM is playing now
SDB.Player.Pause ' Pause MM playback
End If

Hope it helps,
Jiri
Post Reply