Warning message for Windows gamma users
[sdlgit/SDL_perl.git] / lib / SDL / SMPEG.pm
CommitLineData
f757f054 1#!perl
2package SDL::SMPEG;
3
4use strict;
5use warnings;
6use Carp;
7use SDL;
8use SDL::Surface;
9use SDL::MPEG;
10
11sub new {
12 my $proto = shift;
13 my $class = ref($proto) || $proto;
14 my %options = @_;
15
16 verify (%options, qw/ -name -audio / ) if $SDL::DEBUG;
17
18 my $n = $options{-name} || die "SDL::SMPEG must supply a filename to SDL::SMPEG::new\n";
19 my $a = $options{'-audio'} ? 1 : 0;
20 my $info = new SDL::MPEG();
21
22 my $self = \SDL::NewSMPEG($n,$$info,$a);
23 croak SDL::GetError() unless $$self;
24 bless $self,$class;
25 $self->audio(1);
26 $self->video(1);
27 return $self, $info;
28}
29
30sub DESTROY {
31 SDL::FreeSMPEG(${$_[0]});
32}
33
34sub error {
35 SDL::SMPEGError(${$_[0]});
36}
37
38sub audio {
39 SDL::SMPEGEnableAudio( ${$_[0]}, $_[1]);
40}
41
42sub video {
43 SDL::SMPEGEnableSMPEG( ${$_[0]}, $_[1]);
44}
45
46sub volume {
47 SDL::SMPEGSetVolume( ${$_[0]}, $_[1] );
48}
49
50sub display {
51 croak "SDL::SMPEG::Display requires a SDL::Surface\n" unless $_[1]->isa('SDL::Surface');
52 SDL::SMPEGSetDisplay( ${$_[0]}, ${$_[1]}, 0);
53}
54
55sub scale {
56 return SDL::SMPEGScaleXY(${$_[0]},$_[1],$_[2]) if (@_ == 3 );
57 return SDL::SMPEGScaleXY(${$_[0]},$_[1]->width(),$_[1]->height()) if $_[1]->isa('SDL::Surface');
58 SDL::SMPEGScale(${$_[0]},$_[1]);
59}
60
61sub play {
62 SDL::SMPEGPlay(${$_[0]});
63}
64
65sub pause {
66 SDL::SMPEGPause(${$_[0]});
67}
68
69sub stop {
70 SDL::SMPEGStop(${$_[0]});
71}
72
73sub rewind {
74 SDL::SMPEGRewind(${$_[0]});
75}
76
77sub seek {
78 SDL::SMPEGSeek(${$_[0]},$_[1]);
79}
80
81sub skip {
82 SDL::SMPEGSkip(${$_[0]},$_[1]);
83}
84
85sub loop {
86 SDL::SMPEGLoop(${$_[0]},$_[1]);
87}
88
89sub region {
90 croak "SDL::SMPEG::region requires a SDL::Rect\n" unless $_[1]->isa('SDL::Rect');
91 SDL::SMPEGDisplayRegion(${$_[0]},${$_[1]});
92}
93
94sub frame {
95 SDL::SMPEGRenderFrame(${$_[0]},$_[1]);
96}
97
98sub info {
99 new SDL::MPEG -from => $_[0];
100}
101
102sub status {
103 SDL::SMPEGStatus(${$_[0]});
104}
105
1061;
107
108__END__;
109
110=pod
111
112
113=head1 NAME
114
115SDL::SMPEG - a SDL perl extension
116
117=head1 SYNOPSIS
118
119 $video = new SDL::SMPEG ( -name => 'pr0n.mpg' );
120
121=head1 DESCRIPTION
122
123C<SDL::SMPEG> adds support for MPEG video to your
124SDL Perl application. SMPEGs are objects bound to
125surfaces, whose playback is controled through the
126object's interface.
127
128=head2 METHODS
129
130
131=over 4
132
133=item *
134
135C<SDL::SMPEG::error()> returns any error messages associated with playback
136
137=item *
138
139C<SDL::SMPEG::audio(bool)> enables or disables audio playback, (on by default)
140
141=item *
142
143C<SDL::SMPEG::video(bool)> enables or disable video playback, (on by default)
144
145=item *
146
147C<SDL::SMPEG::loop(bool)> enables or disable playback looping (off by default)
148
149=item *
150
151C<SDL::SMPEG::volume(int)> set the volume as per the mixer volume
152
153=item *
154
155C<SDL::SMPEG:display(surface)> binds the clip to a display surface
156
157=item *
158
159C<SDL::SMPEG::scale([x,y]|[surface]|int)> scales the clip by either x,y
160factors, scales to the image dimensions, or a single scalar.
161
162=item *
163
164C<SDL::SMPEG::play()> plays the video clip, call C<SDL::SMPEG::display()> before playing
165
166=item *
167
168C<SDL::SMPEG::pause()> pauses video playback
169
170=item *
171
172C<SDL::SMPEG::stop()> stops video playback
173
174=item *
175
176C<SDL::SMPEG::rewind()> resets the clip to the beginning
177
178=item *
179
180C<SDL::SMPEG::seek(offset)> seeks to a particular byte offset
181
182=item *
183
184C<SDL::SMPEG::skip(time)> skips to a particular time
185
186=item *
187
188C<SDL::SMPEG::region(rect)> takes a SDL::Rect and defines the display area
189
190=item *
191
192C<SDL::SMPEG::frame(int)> renders a specific frame to the screen
193
194=item *
195
196C<SDL::SMPEG::info()> returns a new C<SDL::MPEG> object reflecting the current status
197
198=item *
199
200C<SDL::SMPEG::status()> returns either SMPEG_PLAYING or SMPEG_STOPPED or SMPEG_ERROR
201
202=back
203
204=head1 AUTHOR
205
206David J. Goehrig
207
208=head1 SEE ALSO
209
210perl(1) SDL::Surface(3) SDL::MPEG(3)
211
212=cut
213