Greetings fellow Monks,
I'm working on a perl program that will include video playback, speech synthesis, and speech recognition. Using Win32::MultiMedia::Mci, I can playback video, and using Win32::OLE I can produce speech. But, when I try to combine both these features into a single program, the speech works, but the video no longer plays. The video window is black. Here's what the test code looks like:
use strict;
use Tk;
use Win32::MultiMedia::Mci;
use Win32::OLE;
use Win32::OLE::Const (".*Speech.*");
my $file = shift || 'test.wmv';
my $mw = MainWindow->new();
my $video_frame = $mw->Frame(
-width => 352,
-height => 240,
-background => 'black'
)->pack(-expand => 1);
my $voice = Win32::OLE->new('SAPI.SpVoice');
my $spc = Win32::OLE::Const->Load($voice);
my $timer = $mw->repeat (3000, sub {
$voice->Speak("Wow. I'm multitasking.", $spc->{SVSFlagsAsync});
});
my $mci = Win32::MultiMedia::Mci->open($file,
shareable => 1,
style => 'child',
parent => hex($video_frame->id)
);
$mci->play('');
MainLoop();
If I comment out the 5 lines of speech code (the $voice and $timer definitions), then video playback works. My debug efforts so far include:
1. It's not overloading the CPU. When run individually, the video playback is consuming less than 5 percent of the CPU. Running the video and speech together uses less then 15 percent of the CPU (although the video does not display.)
2. It doesn't appear to be a conflict with the sound card. When only the video is playing, I can run an mp3 player in the background, and I hear the sound for both the mp3 player and the video. When only the speech is playing, I can also hear the mp3 player. So neither feature is claiming exclusive ownership of the sound port.
3. I've tried running the speech engine in synchronous and asynchronous modes. Neither helps the missing video.
4. If I comment out the $timer lines, so that the $voice is instantiated but not used, this still prevents video playback.
Any suggestions on what would cause this conflict?
Thanks,
TROGDOR