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 get() and set() methods:
get()
set()
mplayer_path
This is the path to the mplayer program. This is /usr/bin/mplayer by default.
/usr/bin/mplayer
args
This is a string containing the command line arguments passed to mplayer (no default).
loaded
This is a boolean value that indicates whether the mplayer program is currently running.
state
This is an enumeration (described by Gtk2::Ex::MPlayerEmbed::PlayingState) that indicates the state of the player. state may be one of: stopped, playing, paused. It is stopped at startup.
Gtk2::Ex::MPlayerEmbed::PlayingState
stopped
playing
paused
$embed->play([$content]);
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.
If 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 dvd:// or dvb://.
load
$content
dvd://
dvb://
$embed->pause;
This method will pause the current video stream. If the stream is not playing, this method will carp() and return undef.
$embed->resume;
This is just a convenience wrapper around pause(). The 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.
pause()
$embed->stop;
This method tells mplayer to quit, and resets the widget's internal state. Before loading another video stream with play(), use this method first.
play()
$embed->tell_slave($something);
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.
stream_ended
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.
To install Gtk2::Ex::MPlayerEmbed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gtk2::Ex::MPlayerEmbed
CPAN shell
perl -MCPAN -e shell install Gtk2::Ex::MPlayerEmbed
For more information on module installation, please visit the detailed CPAN module installation guide.