cdrom - Pygame Documentation

pygame documentation | || Pygame Home || Help Contents || Reference Index || Camera || Cdrom || Color || Cursors || Display || Draw || Event || Examples || Font || Gfxdraw || Image || Joystick || Key || Locals || Mask || Midi || Mixer || Mouse || Movie || Music || Overlay || Pixelarray || Pygame || Rect || Scrap || Sndarray || Sprite || Surface || Surfarray || Tests || Time || Transform

pygame.cdrom

pygame module for audio cdrom control

pygame.cdrom.init - initialize the cdrom module | initialize the cdrom module
pygame.cdrom.quit - uninitialize the cdrom module | uninitialize the cdrom module
pygame.cdrom.get_init - true if the cdrom module is initialized | true if the cdrom module is initialized
pygame.cdrom.get_count - number of cd drives on the system | number of cd drives on the system
pygame.cdrom.CD - class to manage a cdrom drive | class to manage a cdrom drive

The cdrom module manages the `CD` and `DVD` drives on a computer. It can also control the playback of audio cd's. This module needs to be initialized before it can do anything. Each `CD` object you create represents a cdrom drive and must also be initialized individually before it can do most things.

pygame.cdrom.init

initialize the cdrom module
`pygame.cdrom.init(): return None`

Initialize the cdrom module. This will scan the system for all `CD` devices. The module must be initialized before any other functions will work. This automatically happens when you call `pygame.init - initialize all imported pygame modules`.

It is safe to call this function more than once.

pygame.cdrom.quit

uninitialize the cdrom module
`pygame.cdrom.quit(): return None`

Uninitialize the cdrom module. After you call this any existing `CD` objects will no longer work.

It is safe to call this function more than once.

pygame.cdrom.get_init

true if the cdrom module is initialized
`pygame.cdrom.get_init(): return bool`

Test if the cdrom module is initialized or not. This is different than the `CD.init - initialize a cdrom drive for use` since each drive must also be initialized individually.

pygame.cdrom.get_count

number of cd drives on the system
`pygame.cdrom.get_count(): return count`

Return the number of cd drives on the system. When you create `CD` objects you need to pass an integer id that must be lower than this count. The count will be 0 if there are no drives on the system.

pygame.cdrom.CD

class to manage a cdrom drive
`pygame.cdrom.CD(id): return CD`

CD.init - initialize a cdrom drive for use | initialize a cdrom drive for use
CD.quit - uninitialize a cdrom drive for use | uninitialize a cdrom drive for use
CD.get_init - true if this cd device initialized | true if this cd device initialized
CD.play - start playing audio | start playing audio
CD.stop - stop audio playback | stop audio playback
CD.pause - temporarily stop audio playback | temporarily stop audio playback
CD.resume - unpause audio playback | unpause audio playback
CD.eject - eject or open the cdrom drive | eject or open the cdrom drive
CD.get_id - the index of the cdrom drive | the index of the cdrom drive
CD.get_name - the system name of the cdrom drive | the system name of the cdrom drive
CD.get_busy - true if the drive is playing audio | true if the drive is playing audio
CD.get_paused - true if the drive is paused | true if the drive is paused
CD.get_current - the current audio playback position | the current audio playback position
CD.get_empty - False if a cdrom is in the drive | False if a cdrom is in the drive
CD.get_numtracks - the number of tracks on the cdrom | the number of tracks on the cdrom
CD.get_track_audio - true if the cdrom track has audio data | true if the cdrom track has audio data
CD.get_all - get all track information | get all track information
CD.get_track_start - start time of a cdrom track | start time of a cdrom track
CD.get_track_length - length of a cdrom track | length of a cdrom track

You can create a `CD` object for each cdrom on the system. Use `pygame.cdrom.get_count - number of cd drives on the system` to determine how many drives actually exist. The id argument is an integer of the drive, starting at zero.

The `CD` object is not initialized, you can only call `CD.get_id - the index of the cdrom drive` and `CD.get_name - the system name of the cdrom drive` on an uninitialized drive.

It is safe to create multiple `CD` objects for the same drive, they will all cooperate normally.

CD.init

initialize a cdrom drive for use
`CD.init(): return None`

Initialize the cdrom drive for use. The drive must be initialized for most `CD` methods to work. Even if the rest of pygame has been initialized.

There may be a brief pause while the drive is initialized. Avoid `CD.init - initialize a cdrom drive for use` if the program should not stop for a second or two.

CD.quit

uninitialize a cdrom drive for use
`CD.quit(): return None`

Uninitialize a drive for use. Call this when your program will not be accessing the drive for awhile.

CD.get_init

true if this cd device initialized
`CD.get_init(): return bool`

Test if this `CDROM` device is initialized. This is different than the `pygame.cdrom.init - initialize the cdrom module` since each drive must also be initialized individually.

CD.play

start playing audio
`CD.play(track, start=None, end=None): return None`

Playback audio from an audio cdrom in the drive. Besides the track number argument, you can also pass a starting and ending time for playback. The start and end time are in seconds, and can limit the section of an audio track played.

If you pass a start time but no end, the audio will play to the end of the track. If you pass a start time and 'None' for the end time, the audio will play to the end of the entire disc.

See the `CD.get_numtracks - the number of tracks on the cdrom` and `CD.get_track_audio - true if the cdrom track has audio data` to find tracks to playback.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.

CD.stop

stop audio playback
`CD.stop(): return None`

Stops playback of audio from the cdrom. This will also lose the current playback position. This method does nothing if the drive isn't already playing audio.

CD.pause

temporarily stop audio playback
`CD.pause(): return None`

Temporarily stop audio playback on the `CD`. The playback can be resumed at the same point with the `CD.resume - unpause audio playback` method. If the `CD` is not playing this method does nothing.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.

CD.resume

unpause audio playback
`CD.resume(): return None`

Unpause a paused `CD`. If the `CD` is not paused or already playing, this method does nothing.

CD.eject

eject or open the cdrom drive
`CD.eject(): return None`

This will open the cdrom drive and eject the cdrom. If the drive is playing or paused it will be stopped.

CD.get_id

the index of the cdrom drive
`CD.get_id(): return id`

Returns the integer id that was used to create the `CD` instance. This method can work on an uninitialized `CD`.

CD.get_name

the system name of the cdrom drive
`CD.get_name(): return name`

Return the string name of the drive. This is the system name used to represent the drive. It is often the drive letter or device name. This method can work on an uninitialized `CD`.

CD.get_busy

true if the drive is playing audio
`CD.get_busy(): return bool`

Returns True if the drive busy playing back audio.

CD.get_paused

true if the drive is paused
`CD.get_paused(): return bool`

Returns True if the drive is currently paused.

CD.get_current

the current audio playback position
`CD.get_current(): return track, seconds`

Returns both the current track and time of that track. This method works when the drive is either playing or paused.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.

CD.get_empty

False if a cdrom is in the drive
`CD.get_empty(): return bool`

Return False if there is a cdrom currently in the drive. If the drive is empty this will return True.

CD.get_numtracks

the number of tracks on the cdrom
`CD.get_numtracks(): return count`

Return the number of tracks on the cdrom in the drive. This will return zero of the drive is empty or has no tracks.

CD.get_track_audio

true if the cdrom track has audio data
`CD.get_track_audio(track): return bool`

Determine if a track on a cdrom contains audio data. You can also call `CD.num_tracks()` and `CD.get_all - get all track information` to determine more information about the cdrom.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.

CD.get_all

get all track information
`CD.get_all(): return [(audio, start, end, lenth), ...]`

Return a list with information for every track on the cdrom. The information consists of a tuple with four values. The audio value is True if the track contains audio data. The start, end, and length values are floating point numbers in seconds. Start and end represent absolute times on the entire disc.

CD.get_track_start

start time of a cdrom track
`CD.get_track_start(track): return seconds`

Return the absolute time in seconds where at start of the cdrom track.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.

CD.get_track_length

length of a cdrom track
`CD.get_track_length(track): return seconds`

Return a floating point value in seconds of the length of the cdrom track.

Note, track 0 is the first track on the `CD`. Track numbers start at zero.