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

Hi All,

I have a piece of code that runs GStreamer in linux written in the following code that I'd like to integrate with a large wxPerl system. Ideally I'd do it using wxMediaCtrl directly but that has totally failed to work (See wxMediaCtrl running under Kubuntu 9.10). So failing that I can find a GStreamer Perl interface and embed that in my application. Unfortunately for me, it uses Glib, which is a new area for me.

So I have this GStreamer code which works (change the avi file name):

#!/usr/bin/perl -w -- use strict; use warnings; use GStreamer -init; my $loop = Glib::MainLoop -> new(); # set up my $file = '/home/steve/media/test.avi'; my $play = GStreamer::ElementFactory -> make("playbin", "play"); $play -> set(uri => Glib::filename_to_uri $file, "localhost"); $play -> get_bus() -> add_watch(\&my_bus_callback, $loop); $play -> set_state("playing"); # run $loop -> run(); # clean up $play -> set_state("null"); sub my_bus_callback { my ($bus, $message, $loop) = @_; if ($message -> type & "error") { warn $message -> error; $loop -> quit(); } elsif ($message -> type & "eos") { $loop -> quit(); } # remove message from the queue return 1; }

and I'd like to include it in a piece of wxPerl code like this: (but have it in the second frame so that I can add other widgets.)

#!/usr/bin/perl -w -- use Wx 0.15 qw[:allclasses]; use strict; use warnings; use GStreamer -init; package MyFrame; use Wx qw[:everything]; use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_ +; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "frame_1" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $sty +le, $name ); my $file = '/home/steve/Documents/Endoscopia/media/a_1_2009_07_30_ +0.avi'; $self->{media_1} = GStreamer::ElementFactory -> make("playbin", "p +lay"); $self->{media_1} -> set(uri => Glib::filename_to_uri $file, "local +host"); $self->{media_1} -> set_state("playing"); $self->{sizer_1} = Wx::BoxSizer->new(wxVERTICAL); #$self->{sizer_1}->Add($self->{media_1}, 0, 0, 0); $self->SetSizer($self->{sizer_1}); $self->{sizer_1}->Fit($self); $self->Layout(); return $self; } 1; package main; unless(caller){ local *Wx::App::OnInit = sub{1}; my $app = Wx::App->new(); Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $app->SetTopWindow($frame_1); $frame_1->Show(1); $app->MainLoop(); }

Any ideas welcome.

Regards

Steve

Replies are listed 'Best First'.
Re: How can I integrate functions from Gtk in wxPerl?
by Anonymous Monk on Nov 12, 2009 at 00:54 UTC
    It will be easier to fix whatever trouble you're having with wxMediaCtrl than to integrate wxperl and gstreamer.
Re: How can I integrate functions from Gtk in wxPerl?
by zentara (Cardinal) on Nov 12, 2009 at 13:15 UTC
    I agree with anonymous monk..... gstreamer is extremely powerful, but difficult to setup. Mplayer works really well on linux.....look at Perl/Tk front-end to mplayer again and try to figure out how to use mplayer in Wx for playing back videos..... there are tons of tutorials for mplayer....gstreamer was meant for more advanced video stuff....like mixing , realtime streams, etc

    ...for just playback of videos, most linux distros use mplayer

    ...i would hazard a guess, that in the Wx design gui, you can make a button, and have it's callback just launch mplayer thru IPC

    ....mplayer will open its own native window, with keyboard functions, and possibly mouse menus....its been a while since i last really delved into it, but it has basic controls builtin


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re: How can I integrate functions from Gtk in wxPerl?
by Steve_BZ (Chaplain) on Nov 12, 2009 at 18:12 UTC
    Updated

    Well I managed to sort out wxMediaCtrl running under Kubuntu 9.10 so although the answer to this is still interesting, I'm not going to pursue actively it any longer.

    Thanks for your help.

    Regards

    Steve