Gtk2::Ex::MPlayerEmbed - a widget to embed the MPlayer media player into GTK+ applications
use Gtk2::Ex::MPlayerEmbed; my $window = Gtk2::Window->new; my $embed = Gtk2::MPlayerEmbed->new; $window->add($embed); $window->show_all; $embed->play("movie.mpg"); Gtk2->main;
Gtk2::Ex::MPlayerEmbed allows you to embed a video player into your applications. It uses the XEMBED system to allow the mplayer program to insert its window into your application.
Glib::Object +----Gtk2::Object +----Gtk2::Widget +----Gtk2::Container +----Gtk2::Socket +----Gtk2::Ex::MPlayerEmbed
The following properties are accessible through the standard Glib
This is the path to the mplayer program. This is
/usr/bin/mplayer by default.
This is a string containing the command line arguments passed to mplayer (no default).
This is a boolean value that indicates whether the mplayer program is currently running.
This is an enumeration (described by
Gtk2::Ex::MPlayerEmbed::PlayingState) that indicates the state of the player.
state may be one of:
paused. It is
stopped at startup.
This method has two behaviours: if the the
loaded property is true (a video stream has been loaded), and the
state property is
paused, then it will resume playing the stream. If
loaded is true but the stream is not paused, then the method will carp() and return undef.
load is false, and the
$content argument is defined, then the player will attempt to load and play the stream identified by
$content, which may be a path to a file, the URL of a network resource, or a "meta-URI" such as
This method will pause the current video stream. If the stream is not playing, this method will carp() and return undef.
This is just a convenience wrapper around
pause() method is really a toggle, and two subsequent calls to
pause() will pause and then resume the stream, so this method exists to disambiguate.
This method tells mplayer to quit, and resets the widget's internal state. Before loading another video stream with
play(), use this method first.
This method sends a command to the mplayer slave process. The available commands are documented in the mplayer-slave-spec.txt file in the source distribution.
1. Do something about controlling aspect ration. We need a way to get the aspect ratio of the video stream, and use a Gtk2::AspectFrame to constrain the shape of the widget.
2. Implement more convenience wrappers around the mplayer command set.
2. Implement a
stream_ended signal that watches the mplayer process and emits when it quits.
GStreamer, for a much more powerful, general purpose multimedia system that's compatible with GTK+.
Gavin Brown (gavin dot brown at uk dot com)
(c) 2005 Gavin Brown. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.