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. |
| [reply] [d/l] |
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 | [reply] [d/l] |
Tcl-only actually available to Perl with http://search.cpan.org/~vkon/, that CPAN module makes available perlTk or pure-Tcl syntax, at your wish.
See my post about video on perlTk at Re: Video components for Tk?
Also you could follow links at the bottom of my home node id to get an idea how to do the trick.
Win32-specific answer to you question is using Win32::OLE to manage existing registered media player.
Best regards,
Courage, the Cowardly Dog
| [reply] |
There is Wx::ActiveX::WMPlayer which I have not yet tried, and a video player using the WxPerl system called videobox with source code. Don't know if useful for you. | [reply] |
in the sample code. is there a way to play multiple video files? i.e. play video1.wmv then video2.wmv then video3.wmv and repeat loop (video1,video2,video3)?
sample code
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();
Thanks
John | [reply] [d/l] |