| Next: GStreamer::Bin | Previous: Gnome2::Wnck::Workspace | [Gtk2-Perl - Table of Contents] | [Gtk2-Perl - Index] |
GStreamer - Perl interface to the GStreamer library
use GStreamer -init;
my $loop = Glib::MainLoop -> new();
# set up
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 TRUE;
}
GStreamer makes everybody dance like crazy. It provides the means to play, stream, and convert nearly any type of media -- be it audio or video. GStreamer wraps the GStreamer library in a nice and Perlish way, freeing the programmer from any memory management and object casting hassles.
When importing GStreamer, you can pass the -init option to have
GStreamer->init automatically called for you. If you need to know if
initialization is possible without actually doing it, use
GStreamer->init_check.