On Sun, 31 Jul 2005 12:00:36 -0400 (EDT) [EMAIL PROTECTED] wrote: >Date: Sun, 31 Jul 2005 13:42:24 +0200 >From: Bo?tjan ?peti? <[EMAIL PROTECTED]> >Subject: mplayer?
>hi >is there an easy way of embeding mplayer into gtk2? >regards, bostjan Hi, I did it with Tk, and had some success embedding mplayer. See script below. First of all, I took an embedding script I was testing with dillo, and just thru the mplayer command into it. It works, but I've included no frills. To see a "frill-full" Tk version, see http://perlmonks.org?node_id=417164 You have to use some special features of mplayer (see it's docs) to run it as a slave. Here is a script that runs on my machine. You will need an init.mpg to give an initial screen, until you load some file. See the above perlmonk link to get the sample files I use. P.S. I played alot with embedding and gtk2, but have only got the mouse to function in the embedded window, no keys connect. ########################################################## #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2; use Gtk2 '-init'; my $pid; #global for killing mplayer on exit my $window = Gtk2::Window->new('toplevel'); $window->set_title('Embed test'); $window ->signal_connect( 'destroy' => \&delete_event ); $window->set_border_width(10); $window->set_size_request(600,600); set_style(); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); $vbox->set_border_width(2); my $hbox= Gtk2::HBox->new( FALSE, 6 ); $vbox->pack_end($hbox,FALSE,FALSE,0); $hbox->set_border_width(2); $vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0); my $vbox1 = Gtk2::VBox->new( FALSE, 6 ); $vbox1->set_size_request(600,500); $vbox->pack_end($vbox1,FALSE,FALSE,0); $vbox1->set_border_width(2); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $hbox->pack_end( $button, FALSE, FALSE, 0 ); $button->signal_connect( clicked => \&delete_event ); my $button1 = Gtk2::Button->new('Mplayer'); $hbox->pack_end( $button1, FALSE, FALSE, 0 ); $button1->signal_connect( clicked => \&do_mplayer ); $window->show_all(); Gtk2->main; ##################################### sub delete_event { kill 9, $pid; Gtk2->main_quit; return FALSE; } ########################################## sub do_mplayer{ my $gdkwindow = $window->window; print "gdkwin->$gdkwindow\n"; my $gdkwindow1 = $vbox1->window; print "gdkvbox->$gdkwindow1\n"; my $xid = $gdkwindow1->XWINDOW; print "xid->$xid\n"; my $url =''; my @options = ( '-slave','-loop 0', '-zoom', "-x 600", "-y 450", '-really-quiet', "-wid $xid", ); my $mpg = 'z-men.mpg'; my $pid = open(MP, "| mplayer @options init.mpg >/dev/null 2>&1 "); syswrite(MP, "loadfile $mpg\n"); } ######################################################################## sub set_style{ Gtk2::Rc->parse_string(<<__); style "normal" { font_name ="serif 12" } style "my_text" { font_name ="sans 12" text[NORMAL] = "#FFAA00" base[NORMAL] = "#000000" GtkTextView::cursor-color = "red" } widget "*" style "normal" widget "*Text*" style "my_text" __ } ####################################################################### -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html _______________________________________________ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list