Ok, here's what I came up with. Seems to work fairly well. It requires at least 3 parameters to be passed to it, file path, zone to play in and screen mode to play in. A 4th can be passed to either shutdown, standby or hibernate the computer after playback stops.
Play test.avi in zone 0 in fullscreen:
mcplayclose.vbs "c:\test.avi" 0 fullscreen
Play test.avi in zone 1 in fullscreen then standby after playback has stopped:
mcplayclose.vbs "c:\test.avi" 0 fullscreen standby
Play the playlist "myplaylist" in zone 0 in fullscreen then shutdown after playback has stopped:
mcplayclose.vbs "TREEPATH=Playlists\myplaylist" 0 fullscreen shutdown
I have 2 uses for this myself. 1) I like to have some music playing at night when I go to bed and can use this to playback a playlist then put the computer into standby after it has finished. 2) Using it for a friend that is using another program to manage his video collection and wants that program to launch MC as the player.
Any feed back is welcome.
' First 3 parameters are required. The 4th shutdown parameter can be left off.
' Parameter 1 is the path to the file to play. Must be given otherwise script will just quit.
' Parameter 2 is the zone to play the file in. Must be by zone index, zone1 is index 0, zone2 is index 1....
' Parameter 3 specifies which mode to play in: Standard, Minime, Fullscreen or Theater
' Parameter 4 specifies to shutdown, standby or hibernate after closing. Must be lower case.
' Sets Repeat off for the specified zone otherwise play never stops and MC never closes and script will continue to run.
' example: mcplayclose.vbs "c:\test.avi" 0 fullscreen
' example: mcplayclose.vbs "c:\test.avi" 0 fullscreen standby
' example: mcplayclose.vbs "TREEPATH=Playlists\myplaylist" 0 fullscreen standby
Dim state, xmlSuccess, objShell, mcURL, filearg, zonearg,_
shutdownarg, screenarg, mcIP, mcPort, mcUserName, mcPassword
mcIP = "127.0.0.1" 'set to your library server IP address
mcPort = "52199" 'set to your library server port number
mcUserName = "" 'set to your library server username
mcPassword = "" 'set to your library server password
Select Case WScript.Arguments.Count
Case 0
WScript.Quit
Case 1
Set args = WScript.Arguments
filearg = args.Item(0)
zonearg = "0"
screenarg = ""
shutdownarg = ""
Case 3
Set args = WScript.Arguments
filearg = args.Item(0)
zonearg = args.Item(1)
screenarg = args.Item(2)
shutdownarg = ""
Case 4
Set args = WScript.Arguments
filearg = args.Item(0)
zonearg = args.Item(1)
screenarg = args.Item(2)
shutdownarg = args.Item(3)
Case Else
WScript.Quit
End Select
if mcUserName = "" then
mcURL = "http://" & mcIP & ":" & mcPort & "/MCWS/v1/Playback/Info?Zone=" & zonearg & "&ZoneType=Index"
else
mcURL = "http://" & mcUserName & ":" & mcPassword & "@" & mcIP &_
":" & mcPort & "/MCWS/v1/Playback/Info?Zone=" & zonearg & "&ZoneType=Index"
end if
Set objShell=WScript.CreateObject("WScript.Shell")
if screenarg <> "" then
objShell.run "C:\Windows\System32\MC16.exe /Mode " & screenarg
WScript.sleep 2000 ' Give MC time to load before issuing next command
end if
objShell.run "C:\Windows\System32\MC16.exe /PlayReplace " & filearg & "|Zone=" & zonearg & "&ZoneType=Index"
WScript.sleep 15000 'Waits 15 seconds for MC's server to initialize, may need to be longer on slower computers
'If you have MC Server set to run at startup then this can be disabaled.
objShell.run "C:\Windows\System32\MC16.exe /MCC 10006, 1:" & zonearg & "&ZoneType=Index" 'Turn off repeat
Set xmlMC = CreateObject("Msxml2.DOMDocument")
xmlMC.async = False
Do
xmlSuccess=xmlMC.load(mcURL) '& "/MCWS/v1/Playback/Info?Zone=" & zonearg & "&ZoneType=Index")
if xmlSuccess <> "True" then
WScript.Echo "Can't Connect to MC"
Set objShell = Nothing
Set xmlMC = Nothing
Set ItemList = Nothing
WScript.Quit
end if
Set ItemList = xmlMC.selectNodes("/Response/Item")
state = ItemList.item(0).Text 'Item 0 in the xml is MC state,value of 0=stopped 1=paused 2=playing
WScript.sleep 2000
Loop While state <> 0
objShell.run "C:\Windows\System32\MC16.exe /Close"
Set xmlMC = Nothing
Set ItemList = Nothing
WScript.sleep 5000
Select Case shutdownarg
Case "shutdown"
objShell.Run "%windir%\System32\shutdown.exe -s -t 0"
Case "standby"
objShell.Run "%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby"
Case "hibernate"
objShell.Run "%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate"
end Select
Set objShell = Nothing
WScript.Quit