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