Source

pygame / docs / ref / cdrom.html

Full commit

<html>
<title>cdrom - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
<a href=display.html>Display</a>&nbsp;||&nbsp;
<a href=draw.html>Draw</a>&nbsp;||&nbsp;
<a href=event.html>Event</a>&nbsp;||&nbsp;
<a href=font.html>Font</a>&nbsp;||&nbsp;
<a href=image.html>Image</a>&nbsp;||&nbsp;
<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
<a href=key.html>Key</a>&nbsp;||&nbsp;
<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
<a href=movie.html>Movie</a>&nbsp;||&nbsp;
<a href=music.html>Music</a>&nbsp;||&nbsp;
<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
<a href=rect.html>Rect</a>&nbsp;||&nbsp;
<a href=scrap.html>Scrap</a>&nbsp;||&nbsp;
<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
<a href=surface.html>Surface</a>&nbsp;||&nbsp;
<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
<a href=time.html>Time</a>&nbsp;||&nbsp;
<a href=transform.html>Transform</a>
</td></tr></table>
<br>


<a name="pygame.cdrom">
<big><b>pygame.cdrom</big></b><br><ul>
  <i>pygame module for audio cdrom control</i><br>
<ul><small><table>
  <tr><td><a href="cdrom.html#pygame.cdrom.init">pygame.cdrom.init</a> - <font size=-1>initialize the cdrom module</font></td><td>initialize the cdrom module</td></tr>
  <tr><td><a href="cdrom.html#pygame.cdrom.quit">pygame.cdrom.quit</a> - <font size=-1>uninitialize the cdrom module</font></td><td>uninitialize the cdrom module</td></tr>
  <tr><td><a href="cdrom.html#pygame.cdrom.get_init">pygame.cdrom.get_init</a> - <font size=-1>true if the cdrom module is initialized</font></td><td>true if the cdrom module is initialized</td></tr>
  <tr><td><a href="cdrom.html#pygame.cdrom.get_count">pygame.cdrom.get_count</a> - <font size=-1>number of cd drives on the system</font></td><td>number of cd drives on the system</td></tr>
  <tr><td><a href="cdrom.html#pygame.cdrom.CD">pygame.cdrom.CD</a> - <font size=-1>class to manage a cdrom drive</font></td><td>class to manage a cdrom drive</td></tr>
</table></small></ul>
<p>The cdrom module manages the <tt>CD</tt> and <tt>DVD</tt> 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 <tt>CD</tt> object you create represents a cdrom drive and must also be initialized individually before it can do most things. </p>
<!--COMMENTS:pygame.cdrom--> &nbsp;<br> 


<a name="pygame.cdrom.init">
<big><b>pygame.cdrom.init</big></b><br><ul>
  <i>initialize the cdrom module</i><br>
  <tt>pygame.cdrom.init(): return None</tt><br>
<p>Initialize the cdrom module. This will scan the system for all <tt>CD</tt> devices. The module must be initialized before any other functions will work. This automatically happens when you call <tt><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></tt>. </p>
<p>It is safe to call this function more than once. </p>
<!--COMMENTS:pygame.cdrom.init--> &nbsp;<br> 
<br></ul>


<a name="pygame.cdrom.quit">
<big><b>pygame.cdrom.quit</big></b><br><ul>
  <i>uninitialize the cdrom module</i><br>
  <tt>pygame.cdrom.quit(): return None</tt><br>
<p>Uninitialize the cdrom module. After you call this any existing <tt>CD</tt> objects will no longer work. </p>
<p>It is safe to call this function more than once. </p>
<!--COMMENTS:pygame.cdrom.quit--> &nbsp;<br> 
<br></ul>


<a name="pygame.cdrom.get_init">
<big><b>pygame.cdrom.get_init</big></b><br><ul>
  <i>true if the cdrom module is initialized</i><br>
  <tt>pygame.cdrom.get_init(): return bool</tt><br>
<p>Test if the cdrom module is initialized or not. This is different than the <tt><a href="cdrom.html#CD.init">CD.init</a> - <font size=-1>initialize a cdrom drive for use</font></tt> since each drive must also be initialized individually. </p>
<!--COMMENTS:pygame.cdrom.get_init--> &nbsp;<br> 
<br></ul>


<a name="pygame.cdrom.get_count">
<big><b>pygame.cdrom.get_count</big></b><br><ul>
  <i>number of cd drives on the system</i><br>
  <tt>pygame.cdrom.get_count(): return count</tt><br>
<p>Return the number of cd drives on the system. When you create <tt>CD</tt> 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. </p>
<!--COMMENTS:pygame.cdrom.get_count--> &nbsp;<br> 
<br></ul>


<a name="pygame.cdrom.CD">
<big><b>pygame.cdrom.CD</big></b><br><ul>
  <i>class to manage a cdrom drive</i><br>
  <tt>pygame.cdrom.CD(id): return CD</tt><br>
<ul><small><table>
  <tr><td><a href="cdrom.html#CD.init">CD.init</a> - <font size=-1>initialize a cdrom drive for use</font></td><td>initialize a cdrom drive for use</td></tr>
  <tr><td><a href="cdrom.html#CD.quit">CD.quit</a> - <font size=-1>uninitialize a cdrom drive for use</font></td><td>uninitialize a cdrom drive for use</td></tr>
  <tr><td><a href="cdrom.html#CD.get_init">CD.get_init</a> - <font size=-1>true if this cd device initialized</font></td><td>true if this cd device initialized</td></tr>
  <tr><td><a href="cdrom.html#CD.play">CD.play</a> - <font size=-1>start playing audio</font></td><td>start playing audio</td></tr>
  <tr><td><a href="cdrom.html#CD.stop">CD.stop</a> - <font size=-1>stop audio playback</font></td><td>stop audio playback</td></tr>
  <tr><td><a href="cdrom.html#CD.pause">CD.pause</a> - <font size=-1>temporarily stop audio playback</font></td><td>temporarily stop audio playback</td></tr>
  <tr><td><a href="cdrom.html#CD.resume">CD.resume</a> - <font size=-1>unpause audio playback</font></td><td>unpause audio playback</td></tr>
  <tr><td><a href="cdrom.html#CD.eject">CD.eject</a> - <font size=-1>eject or open the cdrom drive</font></td><td>eject or open the cdrom drive</td></tr>
  <tr><td><a href="cdrom.html#CD.get_id">CD.get_id</a> - <font size=-1>the index of the cdrom drive</font></td><td>the index of the cdrom drive</td></tr>
  <tr><td><a href="cdrom.html#CD.get_name">CD.get_name</a> - <font size=-1>the system name of the cdrom drive</font></td><td>the system name of the cdrom drive</td></tr>
  <tr><td><a href="cdrom.html#CD.get_busy">CD.get_busy</a> - <font size=-1>true if the drive is playing audio</font></td><td>true if the drive is playing audio</td></tr>
  <tr><td><a href="cdrom.html#CD.get_paused">CD.get_paused</a> - <font size=-1>true if the drive is paused</font></td><td>true if the drive is paused</td></tr>
  <tr><td><a href="cdrom.html#CD.get_current">CD.get_current</a> - <font size=-1>the current audio playback position</font></td><td>the current audio playback position</td></tr>
  <tr><td><a href="cdrom.html#CD.get_empty">CD.get_empty</a> - <font size=-1>False if a cdrom is in the drive</font></td><td>False if a cdrom is in the drive</td></tr>
  <tr><td><a href="cdrom.html#CD.get_numtracks">CD.get_numtracks</a> - <font size=-1>the number of tracks on the cdrom</font></td><td>the number of tracks on the cdrom</td></tr>
  <tr><td><a href="cdrom.html#CD.get_track_audio">CD.get_track_audio</a> - <font size=-1>true if the cdrom track has audio data</font></td><td>true if the cdrom track has audio data</td></tr>
  <tr><td><a href="cdrom.html#CD.get_all">CD.get_all</a> - <font size=-1>get all track information</font></td><td>get all track information</td></tr>
  <tr><td><a href="cdrom.html#CD.get_track_start">CD.get_track_start</a> - <font size=-1>start time of a cdrom track</font></td><td>start time of a cdrom track</td></tr>
  <tr><td><a href="cdrom.html#CD.get_track_length">CD.get_track_length</a> - <font size=-1>length of a cdrom track</font></td><td>length of a cdrom track</td></tr>
</table></small></ul>
<p>You can create a <tt>CD</tt> object for each cdrom on the system. Use <tt><a href="cdrom.html#pygame.cdrom.get_count">pygame.cdrom.get_count</a> - <font size=-1>number of cd drives on the system</font></tt> to determine how many drives actually exist. The id argument is an integer of the drive, starting at zero. </p>
<p>The <tt>CD</tt> object is not initialized, you can only call <tt><a href="cdrom.html#CD.get_id">CD.get_id</a> - <font size=-1>the index of the cdrom drive</font></tt> and <tt><a href="cdrom.html#CD.get_name">CD.get_name</a> - <font size=-1>the system name of the cdrom drive</font></tt> on an uninitialized drive. </p>
<p>It is safe to create multiple <tt>CD</tt> objects for the same drive, they will all cooperate normally. </p>
<!--COMMENTS:pygame.cdrom.CD--> &nbsp;<br> 


<a name="CD.init">
<big><b>CD.init</big></b><br><ul>
  <i>initialize a cdrom drive for use</i><br>
  <tt>CD.init(): return None</tt><br>
<p>Initialize the cdrom drive for use. The drive must be initialized for most <tt>CD</tt> methods to work. Even if the rest of pygame has been initialized. </p>
<p>There may be a brief pause while the drive is initialized. Avoid <tt><a href="cdrom.html#CD.init">CD.init</a> - <font size=-1>initialize a cdrom drive for use</font></tt> if the program should not stop for a second or two. </p>
<!--COMMENTS:CD.init--> &nbsp;<br> 
<br></ul>


<a name="CD.quit">
<big><b>CD.quit</big></b><br><ul>
  <i>uninitialize a cdrom drive for use</i><br>
  <tt>CD.quit(): return None</tt><br>
<p>Uninitialize a drive for use. Call this when your program will not be accessing the drive for awhile. </p>
<!--COMMENTS:CD.quit--> &nbsp;<br> 
<br></ul>


<a name="CD.get_init">
<big><b>CD.get_init</big></b><br><ul>
  <i>true if this cd device initialized</i><br>
  <tt>CD.get_init(): return bool</tt><br>
<p>Test if this <tt>CDROM</tt> device is initialized. This is different than the <tt><a href="cdrom.html#pygame.cdrom.init">pygame.cdrom.init</a> - <font size=-1>initialize the cdrom module</font></tt> since each drive must also be initialized individually. </p>
<!--COMMENTS:CD.get_init--> &nbsp;<br> 
<br></ul>


<a name="CD.play">
<big><b>CD.play</big></b><br><ul>
  <i>start playing audio</i><br>
  <tt>CD.play(track, start=None, end=None): return None</tt><br>
<p>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. </p>
<p>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. </p>
<p>See the <tt><a href="cdrom.html#CD.get_numtracks">CD.get_numtracks</a> - <font size=-1>the number of tracks on the cdrom</font></tt> and <tt><a href="cdrom.html#CD.get_track_audio">CD.get_track_audio</a> - <font size=-1>true if the cdrom track has audio data</font></tt> to find tracks to playback. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.play--> &nbsp;<br> 
<br></ul>


<a name="CD.stop">
<big><b>CD.stop</big></b><br><ul>
  <i>stop audio playback</i><br>
  <tt>CD.stop(): return None</tt><br>
<p>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. </p>
<!--COMMENTS:CD.stop--> &nbsp;<br> 
<br></ul>


<a name="CD.pause">
<big><b>CD.pause</big></b><br><ul>
  <i>temporarily stop audio playback</i><br>
  <tt>CD.pause(): return None</tt><br>
<p>Temporarily stop audio playback on the <tt>CD</tt>. The playback can be resumed at the same point with the <tt><a href="cdrom.html#CD.resume">CD.resume</a> - <font size=-1>unpause audio playback</font></tt> method. If the <tt>CD</tt> is not playing this method does nothing. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.pause--> &nbsp;<br> 
<br></ul>


<a name="CD.resume">
<big><b>CD.resume</big></b><br><ul>
  <i>unpause audio playback</i><br>
  <tt>CD.resume(): return None</tt><br>
<p>Unpause a paused <tt>CD</tt>. If the <tt>CD</tt> is not paused or already playing, this method does nothing. </p>
<!--COMMENTS:CD.resume--> &nbsp;<br> 
<br></ul>


<a name="CD.eject">
<big><b>CD.eject</big></b><br><ul>
  <i>eject or open the cdrom drive</i><br>
  <tt>CD.eject(): return None</tt><br>
<p>This will open the cdrom drive and eject the cdrom. If the drive is playing or paused it will be stopped. </p>
<!--COMMENTS:CD.eject--> &nbsp;<br> 
<br></ul>


<a name="CD.get_id">
<big><b>CD.get_id</big></b><br><ul>
  <i>the index of the cdrom drive</i><br>
  <tt>CD.get_id(): return id</tt><br>
<p>Returns the integer id that was used to create the <tt>CD</tt> instance. This method can work on an uninitialized <tt>CD</tt>. </p>
<!--COMMENTS:CD.get_id--> &nbsp;<br> 
<br></ul>


<a name="CD.get_name">
<big><b>CD.get_name</big></b><br><ul>
  <i>the system name of the cdrom drive</i><br>
  <tt>CD.get_name(): return name</tt><br>
<p>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 <tt>CD</tt>. </p>
<!--COMMENTS:CD.get_name--> &nbsp;<br> 
<br></ul>


<a name="CD.get_busy">
<big><b>CD.get_busy</big></b><br><ul>
  <i>true if the drive is playing audio</i><br>
  <tt>CD.get_busy(): return bool</tt><br>
<p>Returns True if the drive busy playing back audio. </p>
<!--COMMENTS:CD.get_busy--> &nbsp;<br> 
<br></ul>


<a name="CD.get_paused">
<big><b>CD.get_paused</big></b><br><ul>
  <i>true if the drive is paused</i><br>
  <tt>CD.get_paused(): return bool</tt><br>
<p>Returns True if the drive is currently paused. </p>
<!--COMMENTS:CD.get_paused--> &nbsp;<br> 
<br></ul>


<a name="CD.get_current">
<big><b>CD.get_current</big></b><br><ul>
  <i>the current audio playback position</i><br>
  <tt>CD.get_current(): return track, seconds</tt><br>
<p>Returns both the current track and time of that track. This method works when the drive is either playing or paused. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.get_current--> &nbsp;<br> 
<br></ul>


<a name="CD.get_empty">
<big><b>CD.get_empty</big></b><br><ul>
  <i>False if a cdrom is in the drive</i><br>
  <tt>CD.get_empty(): return True</tt><br>
<p>Return False if there is a cdrom currently in the drive. If the drive is open this will return True. </p>
<!--COMMENTS:CD.get_empty--> &nbsp;<br> 
<br></ul>


<a name="CD.get_numtracks">
<big><b>CD.get_numtracks</big></b><br><ul>
  <i>the number of tracks on the cdrom</i><br>
  <tt>CD.get_numtracks(): return count</tt><br>
<p>Return the number of tracks on the cdrom in the drive. This will return zero of the drive is empty or has no tracks. </p>
<!--COMMENTS:CD.get_numtracks--> &nbsp;<br> 
<br></ul>


<a name="CD.get_track_audio">
<big><b>CD.get_track_audio</big></b><br><ul>
  <i>true if the cdrom track has audio data</i><br>
  <tt>CD.get_track_audio(track): return bool</tt><br>
<p>Determine if a track on a cdrom contains audio data. You can also call <tt>CD.num_tracks()</tt> and <tt><a href="cdrom.html#CD.get_all">CD.get_all</a> - <font size=-1>get all track information</font></tt> to determine more information about the cdrom. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.get_track_audio--> &nbsp;<br> 
<br></ul>


<a name="CD.get_all">
<big><b>CD.get_all</big></b><br><ul>
  <i>get all track information</i><br>
  <tt>CD.get_all(): return [(audio, start, end, lenth), ...]</tt><br>
<p>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. </p>
<!--COMMENTS:CD.get_all--> &nbsp;<br> 
<br></ul>


<a name="CD.get_track_start">
<big><b>CD.get_track_start</big></b><br><ul>
  <i>start time of a cdrom track</i><br>
  <tt>CD.get_track_start(track): return seconds</tt><br>
<p>Return the absolute time in seconds where at start of the cdrom track. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.get_track_start--> &nbsp;<br> 
<br></ul>


<a name="CD.get_track_length">
<big><b>CD.get_track_length</big></b><br><ul>
  <i>length of a cdrom track</i><br>
  <tt>CD.get_track_length(track): return seconds</tt><br>
<p>Return a floating point value in seconds of the length of the cdrom track. </p>
<p>Note, track 0 is the first track on the <tt>CD</tt>. Track numbers start at zero. </p>
<!--COMMENTS:CD.get_track_length--> &nbsp;<br> 
<br></ul>
<br></ul>
<br></ul>

</body></html>