Typo with - sign in constant. Causing constants to not be loaded correctly
[sdlgit/SDL_perl.git] / lib / SDL / Cdrom.pm
CommitLineData
8fde61e3 1# Cdrom.pm
2#
3# a SDL cdrom manipluation module
4#
5# Copyright (C) 2000,2002 David J. Goehrig
6#
7
8package SDL::Cdrom;
9use strict;
10
11BEGIN {
12 use Exporter();
13 use vars qw(@ISA @EXPORT);
14 @ISA = qw(Exporter);
15 @EXPORT = qw/ &CD_NUM_DRIVES /;
16}
17
18sub new {
19 my $proto = shift;
20 my $class = ref($proto) || $proto;
21 my $self;
22 my $number = shift;
23 $self = \SDL::CDOpen($number);
24 die SDL::GetError() if ( SDL::CD_ERROR() eq SDL::CDStatus($$self));
25 bless $self,$class;
26 return $self;
27}
28
29sub DESTROY {
30 my $self = shift;
31 SDL::CDClose($$self);
32}
33
34sub CD_NUM_DRIVES {
35 return SDL::CDNumDrives();
36}
37
38sub name ($) {
39 my $self = shift;
40 return SDL::CDName($$self);
41}
42
43sub status ($) {
44 my $self = shift;
45 return SDL::CDstatus($$self);
46}
47
48sub play ($$$;$$) {
49 my ($self,$start,$length,$fs,$fl) = @_;
50 return SDL::CDPlayTracks($$self,$start,$length,$fs,$fl);
51}
52
53sub pause ($) {
54 my $self = shift;
55 return SDL::CDPause($$self);
56}
57
58sub resume ($) {
59 my $self = shift;
60 return SDL::CDResume($$self);
61}
62
63sub stop ($) {
64 my $self = shift;
65 return SDL::CDStop($$self);
66}
67
68sub eject ($) {
69 my $self = shift;
70 return SDL::CDEject($$self);
71}
72
73sub id ($) {
74 my $self = shift;
75 return SDL::CDId($$self);
76}
77
78sub num_tracks ($) {
79 my $self = shift;
80 return SDL::CDNumTracks($$self);
81}
82
83my $buildtrack = sub {
84 my $ptr = shift;
85 my %track = ();
86 $track{-id} = SDL::CDTrackId($ptr);
87 $track{-type} = SDL::CDTrackType($ptr);
88 $track{-length} = SDL::CDTrackLength($ptr);
89 $track{-offset} = SDL::CDTrackOffset($ptr);
90 return \%track;
91};
92
93sub track {
94 my $self = shift;
95 my $number = shift;
96 return &$buildtrack(SDL::CDTrack($$self,$number));
97}
98
99sub current {
100 my $self = shift;
101 return $self->track(SDL::CDCurTrack($$self));
102}
103
104sub current_frame {
105 my $self = shift;
106 return SDL::CDCurFrame($$self);
107}
108
1091;
110
111__END__;
112
113=pod
114
115
116
117=head1 NAME
118
119SDL::Cdrom - a SDL perl extension for managing CD-ROM drives
120
121=head1 SYNOPSIS
122
123 use SDL::Cdrom;
124 $cdrom = SDL::Cdrom->new(0);
125 $cdrom->play();
126
127=head1 EXPORTS
128
129=over 4
130
131=item *
132
133C<CD_NUM_DRIVES>.
134
135=back
136
137=head1 DESCRIPTION
138
139Create a new SDL::Cdrom object. The passed $id is the number of the drive,
140whereas 0 is the first drive etc.
141
142 use SDL::Cdrom;
143 my $drive => SDL::Cdrom->new($id);
144
145=head1 METHODS
146
147=head2 CD_NUM_DRIVES()
148
149Returns the number of CD-ROM drives present.
150
151=head2 name()
152
153Returns the system dependent name of the CD-ROM device.
154
155=head2 status()
156
157Return the status of the drive.
158
159=head2 play()
160
161Play a track.
162
163=head2 pause()
164
165Pause the playing.
166
167=head2 resume()
168
169Resume the playing.
170
171=head2 stop()
172
173Stop the playing.
174
175=head2 eject()
176
177Eject the medium in the drive.
178
179=head2 id()
180
181Return the ID of the drive.
182
183=head2 num_tracks()
184
185Return the number of tracks on the medium.
186
187=head2 track()
188
189Returns the track description
190
191=head2 current()
192
193Return the current played track number.
194
195=head2 current_frame()
196
197Return the current frame.
198
199=head1 AUTHORS
200
201David J. Goehrig
202Documentation by Tels <http://bloodgate.com/>.
203
204=head1 SEE ALSO
205
206L<perl> L<SDL::Mixer> L<SDL::App>.
207
208=cut