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


In reply to How can I integrate functions from Gtk in wxPerl? by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.