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

Hi, I'm looking at ways to place a widget 'MPlayerEmbed' within a widget 'Layout' that need to see in one container, a video with mplayer and an image on the video. My problem is that when I put the widget 'MPlayerEmbed' into the widget 'Layout', the videos are not seen. I tried loading the widget 'MozEmbed' within a widget 'layout' and I do not see the browser. Here this my code:
#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gtk2::Ex::MPlayerEmbed; # Create Main Window my $window = Gtk2::Window->new('toplevel'); $window->set_border_width(0); $window->set_decorated(0); $window->set_position('center-always'); $window->set_title('Player'); $window->signal_connect( destroy => sub { Gtk2->main_quit; } ); $window->set_default_size(1024, 768); my $vbox = Gtk2::VBox->new(0, 0); $vbox->set_border_width(0); # Create a Fixed Container my $layout = Gtk2::Layout->new(); $layout->set_size (1024, 768); $vbox->add($layout); $window->add($vbox); $vbox->show_all; # Create MPLAYER Widget my $mpe = Gtk2::Ex::MPlayerEmbed->new(); $mpe->set('args', $mpe->get('args').' -vo xv'); $layout->put($mpe, 0, 0); $mpe->play('path_to_video.mp4'); $mpe->show_all; $window->show_all; main Gtk2;
I noticed that both (MPlayerEmbed and MozEmbed) are not shown because they are reduced to the size of 1x1. I have not succeeded find a way to put inside a layout widget, a widget MozEmbed or MPlayerEmbed. I hope I understand and I can help. Thanks.
  • Comment on Use widget MPlayerEmbed in Layout container... I can't see the video
  • Download Code

Replies are listed 'Best First'.
Re: Use widget MPlayerEmbed in Layer container... I can't see the video
by zentara (Cardinal) on May 18, 2011 at 15:10 UTC
    Hi, I havn't had any luck with those modules either. Here is a manual way to run mplayer in Gtk2. This works for me, but mplayer always comes in and takes the whole window. If you can figure that out .... :-)

    Notice you need killfam for completely killing mplayer's $pid.

    Updated code for killfam, a few minutes after initial post, soory :-)

    #!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2; use Gtk2 '-init'; use Proc::Killfam; 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); 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 { killfam 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 $init = 'z-men.mpg'; $pid = open(MP, "| mplayer @options $init >/dev/null 2>&1 "); syswrite(MP, "loadfile $mpg\n"); } ########################################

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Well, thanks for your code but not working. When loading the mplayer does nothing and not sends me an error message. I need to load Mplayer and show over it, a image. The ideal way would be using a widget "Layout" or "Fixed" but when I load a video over either of these widget but it is playing, I can not see.