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

Dear fellow monks,

I am writing a Perl/Tk application that should play video files of the format .avi.

The code is part of a larger project but I have created a small perl script that should demonstrate my test case. The problem is the module's unstable behaviour. In other words, in several PCs (and independently of the Windows OS) and/or for some avi files this code works, whereas in other pcs and/or for other avi files it doesn't, i.e. the script does not play the video and at the same time no error is displayed.

My code is as follows:
use Tk; use warnings; use Win32::MultiMedia::Mci; my $file = "pathtofile/file.avi"; my $mw = tkinit; my $counter = 10; my $frame = $mw->Frame(-height => 300, -width =>400)->pack; my $hexid = hex($frame->id); $mci = Win32::MultiMedia::Mci->open($file, 'parent'=>$hexid, 'style'=> +'child'); $mci->play('repeat'); $mw->update; while ($counter > 0) { sleep 1; $counter -=1; } $mci->stop(); $mci->close; Mainloop;
Have you ever used this CPAN module? Do you have any suggestions on what could be wrong?

Thanks very much in advance,
Athanasia

P.S I have ActivePerl-5.8.8.822 installed and have tried the script in several Windows Vista Home Premium, Windows XP notebooks with various results.

Replies are listed 'Best First'.
Re: Unstable behaviour of Win32::MultiMedia module
by marto (Cardinal) on Mar 16, 2009 at 12:18 UTC

    athanasia

    Are you sure the computers in question have the required codecs installed?

    Martin

      Hi Martin,

      Thanks for your reply. I have used Windows Media Player to reproduce all videos in question and in all tested pcs and there was no problem.

      Do you think it is still an issue of codecs? Does that explain the fact that in the case of failed PCs some avi files are displayed and some aren't? Since I should ensure the app works for a wide variety of pcs on which I have no control, what is your suggestion?

      Cheers,
      Athanasia

        athanasia

        Codecs was my first hunch, since I've experienced playback failure due to lack of codec availability in the past. I've not used windows media play in a very long time, due to security concerns, so I am not sure how it deals with codecs. IIRC it attempts to download and install codecs on demand. So in theory had you tested with media player after your app failed to play the video, media player may have downloaded the codec.

        I've never used the module in question, I don't see it in CPAN so I can't help much there. Creating a video player frontend in Perl - what are my options? however has an interesting discussion on a very similar topic, perhaps this is of interest to you.

        Hope this helps

        Martin