5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
42 my $class = ref($proto) || $proto;
45 verify (%options, qw/ -name -audio / ) if $SDL::DEBUG;
47 my $n = $options{-name} || die "SDL::Video must supply a filename to SDL::Video::new\n";
48 my $a = $options{'-audio'} ? 1 : 0;
49 my $info = new SDL::MPEG();
51 my $self = \SDL::NewSMPEG($n,$$info,$a);
52 croak SDL::GetError() unless $$self;
60 SDL::FreeSMPEG(${$_[0]});
64 SDL::SMPEGError(${$_[0]});
68 SDL::SMPEGEnableAudio( ${$_[0]}, $_[1]);
72 SDL::SMPEGEnableVideo( ${$_[0]}, $_[1]);
76 SDL::SMPEGSetVolume( ${$_[0]}, $_[1] );
80 croak "SDL::Video::Display requires a SDL::Surface\n" unless $_[1]->isa('SDL::Surface');
81 SDL::SMPEGSetDisplay( ${$_[0]}, ${$_[1]}, 0);
85 return SDL::SMPEGScaleXY(${$_[0]},$_[1],$_[2]) if (@_ == 3 );
86 return SDL::SMPEGScaleXY(${$_[0]},$_[1]->width(),$_[1]->height()) if $_[1]->isa('SDL::Surface');
87 SDL::SMPEGScale(${$_[0]},$_[1]);
91 SDL::SMPEGPlay(${$_[0]});
95 SDL::SMPEGPause(${$_[0]});
99 SDL::SMPEGStop(${$_[0]});
103 SDL::SMPEGRewind(${$_[0]});
107 SDL::SMPEGSeek(${$_[0]},$_[1]);
111 SDL::SMPEGSkip(${$_[0]},$_[1]);
115 SDL::SMPEGLoop(${$_[0]},$_[1]);
119 croak "SDL::Video::region requires a SDL::Rect\n" unless $_[1]->isa('SDL::Rect');
120 SDL::SMPEGDisplayRegion(${$_[0]},${$_[1]});
124 SDL::SMPEGRenderFrame(${$_[0]},$_[1]);
128 new SDL::MPEG -from => $_[0];
132 SDL::SMPEGStatus(${$_[0]});
144 SDL::Video - a SDL perl extension
148 $video = new SDL::Video ( -name => 'pr0n.mpg' );
152 C<SDL::Video> adds support for MPEG video to your
153 SDL Perl application. Videos are objects bound to
154 surfaces, whose playback is controled through the
164 C<SDL::Video::error()> returns any error messages associated with playback
168 C<SDL::Video::audio(bool)> enables or disables audio playback, (on by default)
172 C<SDL::Video::video(bool)> enables or disable video playback, (on by default)
176 C<SDL::Video::loop(bool)> enables or disable playback looping (off by default)
180 C<SDL::Video::volume(int)> set the volume as per the mixer volume
184 C<SDL::Video:display(surface)> binds the clip to a display surface
188 C<SDL::Video::scale([x,y]|[surface]|int)> scales the clip by either x,y
189 factors, scales to the image dimensions, or a single scalar.
193 C<SDL::Video::play()> plays the video clip, call C<SDL::Video::display()> before playing
197 C<SDL::Video::pause()> pauses video playback
201 C<SDL::Video::stop()> stops video playback
205 C<SDL::Video::rewind()> resets the clip to the beginning
209 C<SDL::Video::seek(offset)> seeks to a particular byte offset
213 C<SDL::Video::skip(time)> skips to a particular time
217 C<SDL::Video::region(rect)> takes a SDL::Rect and defines the display area
221 C<SDL::Video::frame(int)> renders a specific frame to the screen
225 C<SDL::Video::info()> returns a new C<SDL::MPEG> object reflecting the current status
229 C<SDL::Video::status()> returns either SMPEG_PLAYING or SMPEG_STOPPED or SMPEG_ERROR
239 perl(1) SDL::Surface(3) SDL::MPEG(3)