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:
40 my $class = ref($proto) || $proto;
43 verify (%options, qw/ -name -audio / ) if $SDL::DEBUG;
45 my $n = $options{-name} || die "SDL::Video must supply a filename to SDL::Video::new\n";
46 my $a = $options{'-audio'} ? 1 : 0;
47 my $info = new SDL::MPEG();
49 my $self = \SDL::NewSMPEG($n,$$info,$a);
50 die SDL::GetError() unless $$self;
58 SDL::FreeSMPEG(${$_[0]});
62 SDL::SMPEGError(${$_[0]});
66 SDL::SMPEGEnableAudio( ${$_[0]}, $_[1]);
70 SDL::SMPEGEnableVideo( ${$_[0]}, $_[1]);
74 SDL::SMPEGSetVolume( ${$_[0]}, $_[1] );
78 die "SDL::Video::Display requires a SDL::Surface\n" unless $_[1]->isa('SDL::Surface');
79 SDL::SMPEGSetDisplay( ${$_[0]}, ${$_[1]}, 0);
83 return SDL::SMPEGScaleXY(${$_[0]},$_[1],$_[2]) if (@_ == 3 );
84 return SDL::SMPEGScaleXY(${$_[0]},$_[1]->width(),$_[1]->height()) if $_[1]->isa('SDL::Surface');
85 SDL::SMPEGScale(${$_[0]},$_[1]);
89 SDL::SMPEGPlay(${$_[0]});
93 SDL::SMPEGPause(${$_[0]});
97 SDL::SMPEGStop(${$_[0]});
101 SDL::SMPEGRewind(${$_[0]});
105 SDL::SMPEGSeek(${$_[0]},$_[1]);
109 SDL::SMPEGSkip(${$_[0]},$_[1]);
113 SDL::SMPEGLoop(${$_[0]},$_[1]);
117 die "SDL::Video::region requires a SDL::Rect\n" unless $_[1]->isa('SDL::Rect');
118 SDL::SMPEGDisplayRegion(${$_[0]},${$_[1]});
122 SDL::SMPEGRenderFrame(${$_[0]},$_[1]);
126 new SDL::MPEG -from => $_[0];
130 SDL::SMPEGStatus(${$_[0]});
142 SDL::Video - a SDL perl extension
146 $video = new SDL::Video ( -name => 'pr0n.mpg' );
150 C<SDL::Video> adds support for MPEG video to your
151 SDL Perl application. Videos are objects bound to
152 surfaces, whose playback is controled through the
162 C<SDL::Video::error()> returns any error messages associated with playback
166 C<SDL::Video::audio(bool)> enables or disables audio playback, (on by default)
170 C<SDL::Video::video(bool)> enables or disable video playback, (on by default)
174 C<SDL::Video::loop(bool)> enables or disable playback looping (off by default)
178 C<SDL::Video::volume(int)> set the volume as per the mixer volume
182 C<SDL::Video:display(surface)> binds the clip to a display surface
186 C<SDL::Video::scale([x,y]|[surface]|int)> scales the clip by either x,y
187 factors, scales to the image dimensions, or a single scalar.
191 C<SDL::Video::play()> plays the video clip, call C<SDL::Video::display()> before playing
195 C<SDL::Video::pause()> pauses video playback
199 C<SDL::Video::stop()> stops video playback
203 C<SDL::Video::rewind()> resets the clip to the beginning
207 C<SDL::Video::seek(offset)> seeks to a particular byte offset
211 C<SDL::Video::skip(time)> skips to a particular time
215 C<SDL::Video::region(rect)> takes a SDL::Rect and defines the display area
219 C<SDL::Video::frame(int)> renders a specific frame to the screen
223 C<SDL::Video::info()> returns a new C<SDL::MPEG> object reflecting the current status
227 C<SDL::Video::status()> returns either SMPEG_PLAYING or SMPEG_STOPPED or SMPEG_ERROR
237 perl(1) SDL::Surface(3) SDL::MPEG(3)