pygame2.sdl.cdrom – SDL CD-ROM management wrapper

The cdrom module manages the CD and DVD drives on a computer. It can also control the playback of audio CDs.

Module Functions

pygame2.sdl.cdrom.get_name(index) → str

Gets the name of the specified CD- or DVD-ROM drive.

Gets the system-dependent drive name (e.g. “/dev/cdrom” or “D:”) for the CD- or DVD-Rom specified by the passed index.

pygame2.sdl.cdrom.init() → None
Initializes the CD-ROM subsystem of the SDL library.
pygame2.sdl.cdrom.num_drives() → int
Gets the number of accessible CD- and DVD-ROM drives for the system.
pygame2.sdl.cdrom.quit() → None

Shuts down the CD-ROM subsystem of the SDL library.

After calling this function, you should not invoke any class, method or function related to the CD-ROM subsystem as they are likely to fail or might give unpredictable results.

pygame2.sdl.cdrom.was_init() → bool
Returns, whether the CD-ROM subsystem of the SDL library is initialized.

CD

class pygame2.sdl.cdrom.CD(index) → CD

Creates a new CD object for the CD- or DVD-ROM specified by the passed index. The index identifies the matching system CD/DVD-ROM number as returned by cdrom.num_drives ().

The CD itself provides access to the track data on the CD/DVD, playing audio tracks, opening and closing the drive tray and so forth.

Attributes

CD.cur_frame
The current frame offset within the curent track.
CD.cur_track
The current track.
CD.index
The drive index as specified in the constructor.
CD.name
The system-dependent drive name (e.g. “/dev/cdrom” or “D:”).
CD.num_tracks
The total number of tracks on the CD or DVD.
CD.status
Gets the current CD status.
CD.tracks
Gets a list of CDTrack objects with the CD track information.

Methods

CD.close() → None
Releases the CD internals. Useful for e.g. switching CDs within the drive without the need to recreate the CD object. open() will reinitialize the CD internals. You should not use any other method or attribute until a call to open().
CD.eject() → None
Ejects the CD or DVD.
CD.open() → None
(Re-)Opens the CD and initialises the CD internals after a close() call.
CD.pause() → None
Pauses the actual CD playback.
CD.play(start, length[, asfps]) → None
Starts playing the current CD beginning at the give start time for a maximum of length seconds. The start and length arguments are handled as seconds by default. To use an exact frame offset instead ofseconds, pass True as third asfps parameter.
CD.play_tracks([starttrack, ntracks, start, length, asfps]) → None
Plays a certain number of tracks beginning at the passed start track. If start and length are not 0, start determines the offset of starttrack to begin the playback at and length specifies the amount of seconds to play from the last track within the track list. To use an exact frame offset instead of seconds for the start and length parameters, pass True as asfps parameter.
CD.resume() → None
Resumes a previously paused playback.
CD.stop() → None
Stops the current playback.

CDTrack

class pygame2.sdl.cdrom.CDTrack → CDTrack
The CDTrack class provides information about the track contents of a CD or DVD. It should not be created within user code.

Attributes

CDTrack.id
Gets the CD track id.
CDTrack.length
Gets the track length in frames.
CDTrack.minutes
Gets the approximate track length in minutes.
CDTrack.offset
Gets the frame offset of the track on the CD.
CDTrack.seconds
Gets the approximate track length in seconds.
CDTrack.time
Gets the approximate track length in minutes and seconds as tuple.
CDTrack.type
Gets the track type (data or audio).