Using Media Player from a script (sort of).

Posted by Shadowfyr on Wed 18 Jan 2006 10:32 PM — 2 posts, 15,960 views.

USA #0
This bit of script, in VBScript, *almost* works. I say almost, since for some incomprehensible reason it insists any file you open this way is an unrecognized format:

dim wmp
Open_WMP(name, output, wildcards)
  set wmp = createobject("WMPlayer.OCX")
  '"blah" should be replaced with the correct directory,
  'while the trigger/alias passes the name to this function,
  'such as My Song.mp3.
  wmp.openplayer("blah" + wildcards(1)) 
  wmp.controls.play
end

Close_WMP(name, output, wildcards)
  wmp.close 'NOTE: Close the application or the file?
            'I assume the later, since it certainly doesn't
            'close the player.
  set wmp = nothing 'Kill the OCX object, so it stops taking
                    'up memory.
end


Needless to say, this doesn't *quite* work. It may be possible with a playlist or existing media file to use other commands from here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/controlreference.asp

To pick one and play it from the playlist/media list. I haven't tried that though. Giving it the exact path and name however *always* seems to produce a, "Media Player cannot recognize the file type...." error, then a "Can't find the file" type error, even though checking the file properties in the player shows the correct name, path, etc.

I figured this could give people a starting point for a real way to link up WMP with Mushclient, even though it doesn't actually work right at this point. And maybe someone else can figure out how the heck to fix it. ;) lol
USA #1
Found the problem.. Seems Windows Media Player requires you to double the "\", for example:

wmp.openplayer("c:\\My Music\\Music Temp\\Panic Attack.mp3")

Odd thing being that it sets the correct info, even if you don't use \\, but it just won't play the damn things. lol Now if there was just a way to minimize the player or close it through the interface...