SDL::Cdrom - a SDL perl extension
$cdrom = new SDL::Cdrom 0;
Cdrom.pm provides software control for CD music. To open a CD for playing, ejecting, etc. create a new instance of the Cdrom object, passing it the number of the drive starting with 0 .. CD_NUM_DRIVES - 1: $cdrom = new SDL::Cdrom 0;
The function CD_NUM_DRIVES will return the number of accessible drives your system currently has. Once open, you can get the device name of the drive using the method name:
$name = $cdrom->name();
The method $cdrom->status() differs from the SDL function SDL_CDStatus in that it returns a string describing the status. This method returns the following values: playing stopped paused empty error
This was done simply to make it easier to present this information to the end user, in particular programmers debugging their scripts, with little loss of speed.
$cdrom->play(track,number_of_tracks,[frame],[number_of_frames]); $cdrom->pause(); $cdrom->resume(); $cdrom->stop(); $cdrom->eject();
The only tricky thing here is that those familiar with the function SDL_CDPlayTracks should be aware that ntracks and start_frame have been swapped to make it easier to use, with the frame oriented parameters being optional.
To get information on a particular track the method: $cdrom->track(index);
will return a hash containing: -id, the track number as one would see on their cd player, -type, the type of data, -length, size of track in frames, -offset, the posistion on the CD.
returns the hash for the current track, and $cdrom->current_frame will give you the current frame within that track.
logically, returns the number of tracks on the cd, and
returns the id of the cdrom.
David J. Goehrig