1package Audio::CD; 2 3use strict; 4use DynaLoader (); 5 6{ 7 no strict; 8 $VERSION = '0.04'; 9 @ISA = qw(DynaLoader); 10 __PACKAGE__->bootstrap($VERSION); 11} 12 131; 14__END__ 15 16=head1 NAME 17 18Audio::CD - Perl interface to libcdaudio (cd + cddb) 19 20=head1 SYNOPSIS 21 22 use Audio::CD (); 23 my $cd = Audio::CD->init; 24 25=head1 DESCRIPTION 26 27Audio::CD provides a Perl interface to libcdaudio by Tony Arcieri, 28available from http://cdcd.undergrid.net/ 29 30Several classes provide glue for the libcdaudio functions and data 31structures. 32 33=head1 Audio::CD Class 34 35=over 4 36 37=item init 38 39Initialize the Audio::CD object: 40 41 my $cd = Audio::CD->init; 42 43=item stat 44 45Stat the I<Audio::CD> object, returns an I<Audio::CD::Info> object. 46 47 my $info = $cd->stat; 48 49=item cddb 50 51Returns an I<Audio::CDDB> object. 52 53 my $cddb = $cd->cddb; 54 55=item play 56 57Play the given cd track (defaults to 1). 58 59 $cd->play(1); 60 61=item stop 62 63Stop the cd. 64 65 $cd->stop; 66 67=item pause 68 69Pause the cd. 70 71 $cd->pause; 72 73=item resume 74 75Resume the cd. 76 77 $cd->resume; 78 79=item eject 80 81Eject the cd. 82 83 $cd->eject; 84 85=item close 86 87Close the cd tray. 88 89 $cd->close; 90 91=item play_frames 92 93 $cd->play_frames($startframe, $endframe); 94 95=item play_track_pos 96 97 $cd->play_track_pos($strarttrack, $endtrack, $startpos); 98 99=item play_track 100 101 $cd->play_track($strarttrack, $endtrack); 102 103=item track_advance 104 105 $cd->track_advance($endtrack, $minutes, $seconds); 106 107=item advance 108 109 $cd->advance($minutes, $seconds); 110 111=item get_volume 112 113Returns an I<Audio::CD::Volume> object. 114 115 my $vol = $cd->get_volume; 116 117=item set_volume 118 119 $cd->set_volume($vol); 120 121=back 122 123=head1 Audio::CDDB Class 124 125=over 4 126 127=item discid 128 129 my $id = $cddb->discid; 130 131=item lookup 132 133Does a cddb lookup and returns an I<Audio::CD::Data> object. 134 135 my $data = $cddb->lookup; 136 137=back 138 139=item Audio::CD::Data Class 140 141=over 4 142 143=item artist 144 145 my $artist = $data->artist; 146 147=item title 148 149 my $title = $data->title; 150 151=item genre 152 153 my $genre = $data->genre; 154 155=item tracks 156 157Returns an array reference of I<Audio::CD::Track> objects. 158 159=back 160 161=head1 Audio::CD::Track Class 162 163=over 4 164 165=item name 166 167 my $name = $track->name; 168 169=back 170 171=head1 Audio::CD::Info Class 172 173=over 4 174 175=item mode 176 177Returns the CD mode, one of PLAYING, PAUSED, COMPLETED, NOSTATUS; 178 179 my $track = $info->mode; 180 print "playing" if $info->mode == Audio::CD::PLAYING; 181 182=item total_tracks 183 184Returns the total number of tracks on the cd. 185 186 my $track = $info->total_tracks; 187 188=item track_time 189 190Returns the current track play time: 191 192 my($minutes, $seconds) = $info->track_time; 193 194=item time 195 196Returns the current disc play time: 197 198 my($minutes, $seconds) = $info->time; 199 200=item length 201 202Returns the disc length time: 203 204 my($minutes, $seconds) = $info->length; 205 206=item tracks 207 208Returns an array reference of I<Audio::CD::Info::Track> objects. 209 210=back 211 212 213=head1 Audio::CD::Info::Track Class 214 215=over 4 216 217=item length 218 219Returns the track length time: 220 221 my($minutes, $seconds) = $tinfo->length; 222 223=item pos 224 225Returns the track position on the CD: 226 227 my($minutes, $seconds) = $tinfo->pos; 228 229=item type 230 231Returns the track type (either TRACK_AUDIO or TRACK_DATA): 232 233 if ($tinfo->type == Audio::CD::TRACK_AUDIO) { 234 print "audio track\n"; 235 } elsif ($tinfo->type == Audio::CD::TRACK_DATA) { 236 print "data track\n"; 237 } 238 239 240=item is_audio 241 242Returns true if the track is an audio track; equivalent to the test: 243 244 $tinfo->type == Audio::CD::TRACK_AUDIO ? 1 : 0 245 246=item is_data 247 248Returns true if the track is a data track; equivalent to the test: 249 250 $tinfo->type == Audio::CD::TRACK_DATA ? 1 : 0 251 252=back 253 254 255=head1 SEE ALSO 256 257Xmms(3) 258 259=head1 AUTHOR 260 261Perl interface by Doug MacEachern 262 263libcdaudio and cddb_lookup.c by Tony Arcieri 264 265