Re: event_pending question?
- From: Sargonnas <sargonnas satx rr com>
- To: Joern Reder <joern zyn de>
- Cc: <gtk-perl-list gnome org>
- Subject: Re: event_pending question?
- Date: Sat, 23 Nov 2002 23:31:39 -0600 (CST)
Thanks for the help.. now I've just gotta figure out why it keeps spamming
stuff (use of uninitialized value on the console_txt_out line.. only
appeared after changing to this) even after MPlayer is closed. Im assuming
eof isnt working with it, and its not killing it.
On Sat, 23 Nov 2002, Joern Reder wrote:
Sargonnas wrote:
Before you catch the list on fire, Id like to point out that I am a newb
to both perl and gtk-perl. I got bored one day, and started playing around
with making a front-end of sorts for MPlayer.. and it was going along
fairly well, until I came upon a problem. The problem is that when I
attempt to run mplayer, the gui will stop updating. Ive found that
appearantly Gtk->iteration() will keep it from doing this, but I haven't
found out exactly how I should use it... What Im guessing is making this
hard, is the fact that I have it gathering all console output from MPlayer
and inserting it into a text widget. Heres a little code snippet.. any
help would be appreciated.
You need a Gtk::Gdk::input_add for this. Your playmovie() subroutine
doesn't give back the control to Gtk's main event loop. It blocks the
whole program while running mplayer.
It should work like this (hacked into my email client, no warranty for
syntax-error-freeness ;)
--snip--
sub playmovie {
my ($file) = @_;
my $fh = FileHandle->new;
open($fh, "mplayer $file |") or die "can't fork mplayer";
my $handle;
$handle = Gtk::Gdk->input_add (
$fh->fileno, 'read',
sub { got_mplayer_output( $fh, $handle ) }
);
1;
}
sub got_mplayer_output {
my ($fh, $handle) = @_;
if ( eof($fh) ) {
# mplayer exit
Gtk::Gdk->input_remove($handle);
close $fh;
print "mplayer:exit\n";
return 1;
}
my $line = <$fh>;
print "mplayer:$line";
1;
}
--snip--
Hope this helps,
Joern
--
Myrkul, Death and Decay
Sargonnas - The God of Vengeance
-----------------------------------
Faerun's Fall
http://faerun.tamarisk.ab.ca
telnet://faerun.tamarisk.ab.ca:7777
-----------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]