in reply to Playing video with perl / perltk

My target OS is Windows.
On CPAN, windows is called Win32 :D and what you'd do is grab Win32::API and then head on to MSDN and do some reading, so that you can write something similar to Win32::GUI::AxWindow or Wx::ActiveX::WMPlayer or ....

http://perltk.org => http://www.perltk.org/ptknews/recall_me.cgi?Search=video => Re: Embedding media players in Tk ?

Take a look at Win32::MultiMedia (it's on ppm for both ActivePerl 5.6 and 5.8)

It uses the MCI interface to play any kind of audio/video using MediaPlayer. You can embed the video in any Tk frame using the id of the frame:

use strict; use Tk; use Win32::MultiMedia::Mci; my $file = shift || 'test.mpg'; my $video_frame = $mw->Frame( -width => 352, -height => 240, -background => 'black' )->pack(-expand => 1); my $mci = Win32::MultiMedia::Mci->open($file, shareable => 1, style => 'child', parent => hex($frame->id) ); $mci->play('');
Hope this helps, Thomas
update: MCI is as easy as Win32::MCI::Basic (just look at Win32::MCI::CD).

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Playing video with perl / perltk
by TROGDOR (Scribe) on Oct 28, 2004 at 22:29 UTC
    Thanks PodMaster and Courage,
    > But first you must install Tcl/Tk with said widget
    I don't want to deal with a full Tcl install, so I bailed on this idea. But thanks for the suggestion, Courage.
    > Take a look at Win32::MultiMedia
    This worked great! I got it up and running in 5 mins. It did require some debug on the code example, though:
    use strict; use Tk; use Win32::MultiMedia::Mci; my $file = shift || 'test.wmv'; my $mw = MainWindow->new(); my $video_frame = $mw->Frame( -width => 352, -height => 240, -background => 'black' )->pack(-expand => 1); my $mci = Win32::MultiMedia::Mci->open($file, shareable => 1, style => 'child', parent => hex($video_frame->id) ); $mci->play(''); MainLoop();

    There are 3 bugs in the code:
  • $mw was not defined, so I added a MainWindow-new().
  • The mci parent pointed to $frame. It needs to point to $video_frame.
  • Without the MainLoop(), the program exits immediately without playing the video.

    The above code displays a nice little test video window on my screen. This is why I love perl. :)

    Thanks again,
    TROGDOR

    Janitored by Arunbear - replaced pre tags with code tags, as per Monastery guidelines