pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || display || draw || event || || font || image || joystick || key || mixer || mixer_music || || mouse || movie || sndarray || surfarray || time || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Rect || Sound || Surface || || color || cursors || sprite ||

## CD

The CD object represents a CDROM drive and allows you to access the CD inside that drive. All functions (except get_name() and get_id()) require the CD object to be initialized. This is done with the CD.init() function.
Be sure to understand there is a difference between the cdrom module and the CD objects.

eject | - ejects cdrom drive
get_all | - get all track information for the cd
get_busy | - checks if the cd is currently playing
get_current | - get current position of the cdrom
get_empty | - checks for a cd in the drive
get_id | - get device id number for drive
get_init | - check if cd is initialized
get_name | - query name of cdrom drive
get_numtracks | - get number of tracks on cd
get_paused | - checks if the cd is currently paused
get_track_audio | - check if a track has audio data
get_track_length | - check the length of an audio track
get_track_start | - check the start of an audio track
init | - initialize a cdrom device for use
pause | - pause playing cdrom
play | - play music from cdrom
quit | - uninitialize a cdrom device for use
resume | - resume paused cdrom
stop | - stops playing cdrom

eject
`CD.eject() -> None`

Ejects the media from the CDROM drive. If the drive is empty, this will open the CDROM drive.

get_all
`CD.get_all() -> tuple`

Returns a tuple with values for each track on the CD. Each item in the tuple is a tuple with 4 values for each track. First is a boolean set to true if this is an audio track. The next 3 values are the start time, end time, and length of the track.

get_busy
`CD.get_busy() -> bool`

Returns a true value if the cd drive is currently playing. If the drive is paused, this will return false.

get_current
`CD.get_current() -> track, seconds`

Returns the current track on the cdrom and the number of seconds into that track.

get_empty
`CD.get_empty() -> bool`

Returns a true value if the cd drive is empty.

get_id
`CD.get_id() -> idnum`

Returns the device id number for this cdrom drive. This is the same number used in the call to pygame.cdrom.CD() to create this cd device. The CD object does not need to be initialized for this function to work.

get_init
`CD.get_init() -> bool`

Returns a true value if the CD is initialized.

get_name
`CD.get_name(id) -> string`

Returns the name of the CDROM device, given by the system. This function can be called before the drive is initialized.

get_numtracks
`CD.get_numtracks() -> numtracks`

Returns the number of available tracks on the CD. Note that not all of these tracks contain audio data. Use CD.get_track_audio() to check the track type before playing.

get_paused
`CD.get_paused() -> bool`

Returns a true value if the cd drive is currently paused.

get_track_audio
`CD.get_track_audio(track) -> bool`

Returns true if the cdrom track contains audio data.

get_track_length
`CD.get_track_length(track) -> seconds`

Returns the number of seconds in an audio track. If the track does not contain audio data, returns 0.0.

get_track_start
`CD.get_track_start(track) -> seconds`

Returns the number of seconds an audio track starts on the cd.

init
`CD.init() -> None`

In order to call most members in the CD object, the CD must be initialized. You can initialzie the CD object at anytime, and it is ok to initialize more than once.

pause
`CD.pause() -> None`

Pauses the playing CD. If the CD is not playing, this will do nothing.

play
`CD.play(track, [start, end]) -> None`

Play an audio track on a cdrom disk. You may also optionally pass a starting and ending time to play of the song. If you pass the start and end time in seconds, only that portion of the audio track will be played. If you only provide a start time and no end time, this will play to the end of the track. You can also pass 'None' as the ending time, and it will play to the end of the cd.

quit
`CD.quit() -> None`

After you are completely finished with a cdrom device, you can use this quit() function to free access to the drive. This will be cleaned up automatically when the cdrom module is. uninitialized. It is safe to call this function on an uninitialized CD.

resume
`CD.resume() -> int`

Resumes playback of a paused CD. If the CD has not been pause, this will do nothing.

stop
`CD.stop() -> int`

Stops the playing CD. If the CD is not playing, this will do nothing.