NAME
Video::Xine - Perl interface to libxine
SYNOPSIS
use Video::Xine;
# Create and initialize the Xine object
my $xine = Video::Xine->new(
config_file => "$ENV{'HOME'}/.xine/config",
);
# Load a video driver
my $video_driver = Video::Xine::Driver::Video->new($xine,"auto",1,$x11_visual);
# Create a new stream (put your video driver under $DRIVER)
my $stream = $xine->stream_new(undef,$DRIVER);
# Open a file on the stream
$stream->open('file://my/movie/file.avi')
or die "Couldn't open stream: ", $stream->get_error();
# Get the current position (0 .. 65535), position in time, and length
# of stream in milliseconds
my ($pos, $pos_time, $length_time) = $stream->get_pos_length();
# Start the stream playing
$stream->play()
or die "Couldn't play stream: ", $xine->get_error();
# Play the stream to the end
while ( $xine->get_status() == XINE_STATUS_PLAY ) {
sleep(1);
}
DESCRIPTION
A perl interface to Xine, the Linux movie player. More properly, an interface to libxine, the development library. Requires installation of libxine.
Xine by itself does not provide a user interface, and neither does this interface. Instead, you must set up the window using your own windowing code, and pass the window information to Xine.
METHODS
new()
Constructor. Takes named argument 'config_file'.
set_param()
set_param($param, $value);
Sets an engine parameter. Currently, this is only useful for setting the Xine logging level.
stream_new()
stream_new($audio_port, $video_port)
Creates a new stream. The $audio_port
and $video_port
options are optional and default to automatically-selected drivers. A convenience method around Xine::Stream::new.
STREAM METHODS
These are methods which can be used on the Video::Xine::Stream class and object.
new()
new($xine, $audio_port, $video_port)
Creates a new Stream object. The $audio_port
and $video_port
options are optional and default to automatically-selected drivers.
get_video_port()
Returns the video port, also known as the video driver.
open()
open($mrl)
Opens the stream to an MRL, which is a URL-like construction used by Xine to locate media files. See the xine documentation for details.
play()
play($start_pos, $start_time)
Starts playing the stream at a specific position or specific time. Both $start_pos
and $start_time
are optional and default to 0.
stop()
Stops the stream.
close()
Close the stream. You can re-use the same stream again and again.
get_pos_length()
($pos_pct, $pos_time, $length_time) = $s->get_pos_length();
Gets position / length information. $pos_pct
is a value between 1 and 65535 indicating how far we've proceeded through the stream. $pos_time
gives how far we've proceeded through the stream in milliseconds, and $length_time
gives the total length of the stream in milliseconds.
get_status()
Returns the play status of the stream.
XINE_STATUS_STOP
Indicates that the stream is stopped.
XINE_STATUS_PLAY
Indicates that the stream is playing.
get_error()
Returns the last error message.
set_param()
$s->set_param($param, $value)
Sets a parameter on the stream. $param
should be a xine parameter constant. See xine.h for details.
get_param()
$s->get_param($param)
Returns a parameter from the stream. $param
should be a xine parameter constant.
AUDIO DRIVER METHODS
new()
new($xine, $id, $data)
Creates a new audio driver for opening streams. $id
and $data
are optional. Returns undef on failure. If $id
is undefined, returns Xine's idea of the default audio driver.
Example:
# Creates an audio driver that doesn't make any noise
my $audio_driver = Video::Xine::Driver::Audio->new($xine, 'none')
or die "Couldn't load audio driver!";
VIDEO DRIVER METHODS
new()
new($xine, $id, $visual, $data)
Returns a video driver which can be used to open streams. id
, $visual
, and $data
are optional. If $id
is undefined, returns an automatically-chosen driver.
$visual
is the visual type, which should be an integer. Video::Xine provides a series of constants indicating the different visual types:
XINE_VISUAL_TYPE_NONE
XINE_VISUAL_TYPE_X11
XINE_VISUAL_TYPE_X11_2
XINE_VISUAL_TYPE_AA
XINE_VISUAL_TYPE_FB
XINE_VISUAL_TYPE_GTK
XINE_VISUAL_TYPE_DFB
XINE_VISUAL_TYPE_PM
XINE_VISUAL_TYPE_DIRECTX
XINE_VISUAL_TYPE_CACA
XINE_VISUAL_TYPE_MACOSX
XINE_VISUAL_TYPE_XCB
$data
is an opaque value dependent on the visual type. For XINE_VISUAL_TYPE_X11, $data
is of type x11_visual_type
, a C struct which should be created with with the method Video::Xine::Util::make_x11_visual()
.
Example:
my $display = X11::FullScreen::Display->new($display_str);
my $x11_visual = Video::Xine::Util::make_x11_visual($display,
$display->getDefaultScreen(),
$display->createWindow(),
$display->getWidth(),
$display->getHeight(),
$display->getPixelAspect()
);
my $driver = Video::Xine::Driver::Video->new($xine,"Xv",XINE_VISUAL_TYPE_X11, $x11_visual)
or die "Couldn't load video driver";
UTILITY SUBROUTINES
These subroutines are found in the package Video::Xine::Util.
make_x11_visual()
make_x11_visual($x_display, $screen, $window_id, $width, $height, $aspect)
Returns a C struct suitable for passing to the Video::Xine::Driver::Video constructor with a XINE_VISUAL_TYPE_X11.
BUGS
Due to Perl's unordered garbage collection during global destruction, Video::Xine may cause a segmentation fault as your program terminates. The current workaround is to make sure that your drivers are garbage-collected before your Xine instance by explicitly setting them to undef before the end of the program.
This code is in BETA state. I do not expect major API changes.
SEE ALSO
AUTHOR
Stephen Nelson, <stephen@cpan.org>
SPECIAL THANKS TO
Joern Reder
COPYRIGHT AND LICENSE
Copyright (C) 2005-2008 by Stephen Nelson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.