Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm still banging my head against unsolved problem. I'm still trying to get control of Windows Media Player through Perl and OLE. I cannot find any easy docs on this matter, so just have to try a lot. I wonder if anyone is willing to help me out - I need to specify file, get fullscreen video and at the end stop. My code (I know it's ugly) - I get About box but no video at all:
use Win32::OLE; use Win32::OLE::Variant; my $player= Win32::OLE->new('MediaPlayer.MediaPlayer') or die Win32::OLE->LastError(); $player->{'Autostart'} = Variant(VT_BOOL, 1) or die Win32::OLE->LastE +rror(); $player->{'FileName'} = "C:\\d\\media\\video\\Maratonci.avi" or die Wi +n32::OLE->LastError(); print "FileName = $player->{FileName}\n"; sleep(5); $player->AboutBox; sleep(5); $player->Invoke(Play) ; #$player->Play or die Win32::OLE->LastError(); sleep(30); $player->Quit() or die Win32::OLE->LastError();

Replies are listed 'Best First'.
Re: Trouble with WMP and OLE
by blm (Hermit) on Mar 02, 2003 at 07:19 UTC

    After digging around at the Media Player Object Documentation, it would seem that the thing (MediaPlayer.MediaPlayer) is actually an ActiveX control that needs to be embedded in an ActiveX container like a VB form or a web page in Internet Explorer. This was confirmed for me when I saw this. The author of that web page created a wrapper around media player and a scriptable object to create forms to embed ActiveX controls in. Give it a look as it may help. It relates specifically to WSH but you can translate alot of VBScript to perl using Win32::OLE.

      Thanks for help, the funny thing is that I get About box show OK from code I have. So I assume that also other things should work - but I'm really novice to OLE, so maybe I'm doing something wron in code - maybe just turning WMP to be visible would be enough to get averything working. So maybe if someone explained to me how to set properties, how to call methods correctly with Perl and OLE that would be good start for me... Regards, Robert Rozman
Re: Trouble with WMP and OLE
by Zero_Flop (Pilgrim) on Mar 02, 2003 at 17:10 UTC
    AM-

    I have several examples of using OLE I can foward off to you, They are not directly related to this thread, so I am hesident to publish here. But they may be of use getting a little closer to OLE. If you are interested feel free to drop me a line. I have not worked with media player.

    ZF
    xn_murphy@charter.net - Remove the x
      Please do, it will help me a lot. Regards, Robert Rozman