The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Gtk2::Ex::MPlayerEmbed - a widget to embed the MPlayer media player into GTK+ applications

SYNOPSIS

        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;

DESCRIPTION

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.

OBJECT HIERARCHY

  Glib::Object
  +----Gtk2::Object
       +----Gtk2::Widget
            +----Gtk2::Container
                 +----Gtk2::Socket
                      +----Gtk2::Ex::MPlayerEmbed

PROPERTIES

The following properties are accessible through the standard Glib get() and set() methods:

mplayer_path

This is the path to the mplayer program. This is /usr/bin/mplayer by default.

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.

METHODS

        $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://.

        $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.

        $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.

        $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.

PREREQUISITES

Gtk2
The mplayer program, available from http://www.mplayerhq.hu/.

TODO

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.

SEE ALSO

GStreamer, for a much more powerful, general purpose multimedia system that's compatible with GTK+.

AUTHOR

Gavin Brown (gavin dot brown at uk dot com)

COPYRIGHT

(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.