Re: Are there Perl bindings for gstreamer-1.0?
- From: Terence Ferraro <terencejferraro gmail com>
- To: Steve Cookson <it sca-uk com>
- Cc: GTK-Perl List <gtk-perl-list gnome org>
- Subject: Re: Are there Perl bindings for gstreamer-1.0?
- Date: Sun, 27 Apr 2014 02:42:51 -0400
I did a little more playing around with this...
Here's my working example:
#!/usr/bin/perl -w
use strict;
use Glib;
use Gtk3 -init;
Gst::init();
my $play = Gst::ElementFactory->new("playbin","play");
my $fn = "
http://www.csoft.co.uk/video/original/earth.avi";
$play->set_uri($fn);
$play->set_state('playing');
my $bus = $play->get_bus;
my $int = $bus->add_watch(\&my_callback);
Gtk3::main;
sub my_callback
{
my ($bus, $message) = @_;
if ($message->type =~ /error/)
{
warn "error\n";
Gtk3->main_quit;
exit;
}
elsif ($message->type =~ /eos/)
{
warn "end\n";
Gtk3->main_quit;
exit;
}
return 1;
}
Accomplished by placing the following in my Gtk3.pm file (in their respective portions of the file, left to the reader):
my $_GST_BASENAME = 'Gst';
my $_GST_VERSION = '1.0';
my $_GST_PACKAGE = 'Gst';
Glib::Object::Introspection->setup (
basename => $_GST_BASENAME,
version => $_GST_VERSION,
package => $_GST_PACKAGE);
sub Gst::init {
Glib::Object::Introspection->invoke ($_GST_BASENAME, undef, 'init', undef);
}
sub Gst::ElementFactory::new
{
my ($self,$factory_name,$name) = @_;
my $e = Gst::ElementFactory::make($factory_name,$name);
my $package = 'Gst::Element';
return bless $e, $package;
}
sub Gst::Element::set_uri
{
my ($self,$uri) = @_;
Glib::Object::set($self,'uri' => $uri);
}
sub Gst::Bus::add_watch
{
my ($self,$callback,$data) = @_;
my $int = Glib::Object::Introspection->invoke ('Gst', 'Bus', 'add_watch',$self,0,$callback,$data);
return($int);
}
Not sure if that's of use to anyone, but, hey, it works :)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]