| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="cd-parser-objects.html" /> |
| 13 | <link rel="prev" href="module-cd.html" /> |
| 14 | <link rel="parent" href="module-cd.html" /> |
| 15 | <link rel="next" href="cd-parser-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>20.3.1 Player Objects</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="20.3 cd " |
| 25 | href="module-cd.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="20.3 cd " |
| 28 | href="module-cd.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="20.3.2 Parser Objects" |
| 31 | href="cd-parser-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-cd.html">20.3 cd </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="module-cd.html">20.3 cd </A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="cd-parser-objects.html">20.3.2 Parser Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H2><A NAME="SECTION0022310000000000000000"></A> |
| 56 | <A NAME="player-objects"></A> |
| 57 | <BR> |
| 58 | 20.3.1 Player Objects |
| 59 | </H2> |
| 60 | |
| 61 | <P> |
| 62 | Player objects (returned by <tt class="function">open()</tt>) have the following |
| 63 | methods: |
| 64 | |
| 65 | <P> |
| 66 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 67 | <td><nobr><b><tt id='l2h-5088' xml:id='l2h-5088' class="method">allowremoval</tt></b>(</nobr></td> |
| 68 | <td><var></var>)</td></tr></table></dt> |
| 69 | <dd> |
| 70 | Unlocks the eject button on the CD-ROM drive permitting the user to |
| 71 | eject the caddy if desired. |
| 72 | </dl> |
| 73 | |
| 74 | <P> |
| 75 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 76 | <td><nobr><b><tt id='l2h-5089' xml:id='l2h-5089' class="method">bestreadsize</tt></b>(</nobr></td> |
| 77 | <td><var></var>)</td></tr></table></dt> |
| 78 | <dd> |
| 79 | Returns the best value to use for the <var>num_frames</var> parameter of |
| 80 | the <tt class="method">readda()</tt> method. Best is defined as the value that |
| 81 | permits a continuous flow of data from the CD-ROM drive. |
| 82 | </dl> |
| 83 | |
| 84 | <P> |
| 85 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 86 | <td><nobr><b><tt id='l2h-5090' xml:id='l2h-5090' class="method">close</tt></b>(</nobr></td> |
| 87 | <td><var></var>)</td></tr></table></dt> |
| 88 | <dd> |
| 89 | Frees the resources associated with the player object. After calling |
| 90 | <tt class="method">close()</tt>, the methods of the object should no longer be used. |
| 91 | </dl> |
| 92 | |
| 93 | <P> |
| 94 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 95 | <td><nobr><b><tt id='l2h-5091' xml:id='l2h-5091' class="method">eject</tt></b>(</nobr></td> |
| 96 | <td><var></var>)</td></tr></table></dt> |
| 97 | <dd> |
| 98 | Ejects the caddy from the CD-ROM drive. |
| 99 | </dl> |
| 100 | |
| 101 | <P> |
| 102 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 103 | <td><nobr><b><tt id='l2h-5092' xml:id='l2h-5092' class="method">getstatus</tt></b>(</nobr></td> |
| 104 | <td><var></var>)</td></tr></table></dt> |
| 105 | <dd> |
| 106 | Returns information pertaining to the current state of the CD-ROM |
| 107 | drive. The returned information is a tuple with the following values: |
| 108 | <var>state</var>, <var>track</var>, <var>rtime</var>, <var>atime</var>, <var>ttime</var>, |
| 109 | <var>first</var>, <var>last</var>, <var>scsi_audio</var>, <var>cur_block</var>. |
| 110 | <var>rtime</var> is the time relative to the start of the current track; |
| 111 | <var>atime</var> is the time relative to the beginning of the disc; |
| 112 | <var>ttime</var> is the total time on the disc. For more information on |
| 113 | the meaning of the values, see the man page <span class="manpage"><i>CDgetstatus</i>(3dm)</span>. |
| 114 | The value of <var>state</var> is one of the following: <tt class="constant">ERROR</tt>, |
| 115 | <tt class="constant">NODISC</tt>, <tt class="constant">READY</tt>, <tt class="constant">PLAYING</tt>, |
| 116 | <tt class="constant">PAUSED</tt>, <tt class="constant">STILL</tt>, or <tt class="constant">CDROM</tt>. |
| 117 | </dl> |
| 118 | |
| 119 | <P> |
| 120 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 121 | <td><nobr><b><tt id='l2h-5093' xml:id='l2h-5093' class="method">gettrackinfo</tt></b>(</nobr></td> |
| 122 | <td><var>track</var>)</td></tr></table></dt> |
| 123 | <dd> |
| 124 | Returns information about the specified track. The returned |
| 125 | information is a tuple consisting of two elements, the start time of |
| 126 | the track and the duration of the track. |
| 127 | </dl> |
| 128 | |
| 129 | <P> |
| 130 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 131 | <td><nobr><b><tt id='l2h-5094' xml:id='l2h-5094' class="method">msftoblock</tt></b>(</nobr></td> |
| 132 | <td><var>min, sec, frame</var>)</td></tr></table></dt> |
| 133 | <dd> |
| 134 | Converts a minutes, seconds, frames triple representing a time in |
| 135 | absolute time code into the corresponding logical block number for the |
| 136 | given CD-ROM drive. You should use <tt class="function">msftoframe()</tt> rather than |
| 137 | <tt class="method">msftoblock()</tt> for comparing times. The logical block number |
| 138 | differs from the frame number by an offset required by certain CD-ROM |
| 139 | drives. |
| 140 | </dl> |
| 141 | |
| 142 | <P> |
| 143 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 144 | <td><nobr><b><tt id='l2h-5095' xml:id='l2h-5095' class="method">play</tt></b>(</nobr></td> |
| 145 | <td><var>start, play</var>)</td></tr></table></dt> |
| 146 | <dd> |
| 147 | Starts playback of an audio CD in the CD-ROM drive at the specified |
| 148 | track. The audio output appears on the CD-ROM drive's headphone and |
| 149 | audio jacks (if fitted). Play stops at the end of the disc. |
| 150 | <var>start</var> is the number of the track at which to start playing the |
| 151 | CD; if <var>play</var> is 0, the CD will be set to an initial paused |
| 152 | state. The method <tt class="method">togglepause()</tt> can then be used to commence |
| 153 | play. |
| 154 | </dl> |
| 155 | |
| 156 | <P> |
| 157 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 158 | <td><nobr><b><tt id='l2h-5096' xml:id='l2h-5096' class="method">playabs</tt></b>(</nobr></td> |
| 159 | <td><var>minutes, seconds, frames, play</var>)</td></tr></table></dt> |
| 160 | <dd> |
| 161 | Like <tt class="method">play()</tt>, except that the start is given in minutes, |
| 162 | seconds, and frames instead of a track number. |
| 163 | </dl> |
| 164 | |
| 165 | <P> |
| 166 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 167 | <td><nobr><b><tt id='l2h-5097' xml:id='l2h-5097' class="method">playtrack</tt></b>(</nobr></td> |
| 168 | <td><var>start, play</var>)</td></tr></table></dt> |
| 169 | <dd> |
| 170 | Like <tt class="method">play()</tt>, except that playing stops at the end of the |
| 171 | track. |
| 172 | </dl> |
| 173 | |
| 174 | <P> |
| 175 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 176 | <td><nobr><b><tt id='l2h-5098' xml:id='l2h-5098' class="method">playtrackabs</tt></b>(</nobr></td> |
| 177 | <td><var>track, minutes, seconds, frames, play</var>)</td></tr></table></dt> |
| 178 | <dd> |
| 179 | Like <tt class="method">play()</tt>, except that playing begins at the specified |
| 180 | absolute time and ends at the end of the specified track. |
| 181 | </dl> |
| 182 | |
| 183 | <P> |
| 184 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 185 | <td><nobr><b><tt id='l2h-5099' xml:id='l2h-5099' class="method">preventremoval</tt></b>(</nobr></td> |
| 186 | <td><var></var>)</td></tr></table></dt> |
| 187 | <dd> |
| 188 | Locks the eject button on the CD-ROM drive thus preventing the user |
| 189 | from arbitrarily ejecting the caddy. |
| 190 | </dl> |
| 191 | |
| 192 | <P> |
| 193 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 194 | <td><nobr><b><tt id='l2h-5100' xml:id='l2h-5100' class="method">readda</tt></b>(</nobr></td> |
| 195 | <td><var>num_frames</var>)</td></tr></table></dt> |
| 196 | <dd> |
| 197 | Reads the specified number of frames from an audio CD mounted in the |
| 198 | CD-ROM drive. The return value is a string representing the audio |
| 199 | frames. This string can be passed unaltered to the |
| 200 | <tt class="method">parseframe()</tt> method of the parser object. |
| 201 | </dl> |
| 202 | |
| 203 | <P> |
| 204 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 205 | <td><nobr><b><tt id='l2h-5101' xml:id='l2h-5101' class="method">seek</tt></b>(</nobr></td> |
| 206 | <td><var>minutes, seconds, frames</var>)</td></tr></table></dt> |
| 207 | <dd> |
| 208 | Sets the pointer that indicates the starting point of the next read of |
| 209 | digital audio data from a CD-ROM. The pointer is set to an absolute |
| 210 | time code location specified in <var>minutes</var>, <var>seconds</var>, and |
| 211 | <var>frames</var>. The return value is the logical block number to which |
| 212 | the pointer has been set. |
| 213 | </dl> |
| 214 | |
| 215 | <P> |
| 216 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 217 | <td><nobr><b><tt id='l2h-5102' xml:id='l2h-5102' class="method">seekblock</tt></b>(</nobr></td> |
| 218 | <td><var>block</var>)</td></tr></table></dt> |
| 219 | <dd> |
| 220 | Sets the pointer that indicates the starting point of the next read of |
| 221 | digital audio data from a CD-ROM. The pointer is set to the specified |
| 222 | logical block number. The return value is the logical block number to |
| 223 | which the pointer has been set. |
| 224 | </dl> |
| 225 | |
| 226 | <P> |
| 227 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 228 | <td><nobr><b><tt id='l2h-5103' xml:id='l2h-5103' class="method">seektrack</tt></b>(</nobr></td> |
| 229 | <td><var>track</var>)</td></tr></table></dt> |
| 230 | <dd> |
| 231 | Sets the pointer that indicates the starting point of the next read of |
| 232 | digital audio data from a CD-ROM. The pointer is set to the specified |
| 233 | track. The return value is the logical block number to which the |
| 234 | pointer has been set. |
| 235 | </dl> |
| 236 | |
| 237 | <P> |
| 238 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 239 | <td><nobr><b><tt id='l2h-5104' xml:id='l2h-5104' class="method">stop</tt></b>(</nobr></td> |
| 240 | <td><var></var>)</td></tr></table></dt> |
| 241 | <dd> |
| 242 | Stops the current playing operation. |
| 243 | </dl> |
| 244 | |
| 245 | <P> |
| 246 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 247 | <td><nobr><b><tt id='l2h-5105' xml:id='l2h-5105' class="method">togglepause</tt></b>(</nobr></td> |
| 248 | <td><var></var>)</td></tr></table></dt> |
| 249 | <dd> |
| 250 | Pauses the CD if it is playing, and makes it play if it is paused. |
| 251 | </dl> |
| 252 | |
| 253 | <P> |
| 254 | |
| 255 | <DIV CLASS="navigation"> |
| 256 | <div class='online-navigation'> |
| 257 | <p></p><hr /> |
| 258 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 259 | <tr> |
| 260 | <td class='online-navigation'><a rel="prev" title="20.3 cd " |
| 261 | href="module-cd.html"><img src='../icons/previous.png' |
| 262 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 263 | <td class='online-navigation'><a rel="parent" title="20.3 cd " |
| 264 | href="module-cd.html"><img src='../icons/up.png' |
| 265 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 266 | <td class='online-navigation'><a rel="next" title="20.3.2 Parser Objects" |
| 267 | href="cd-parser-objects.html"><img src='../icons/next.png' |
| 268 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 269 | <td align="center" width="100%">Python Library Reference</td> |
| 270 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 271 | href="contents.html"><img src='../icons/contents.png' |
| 272 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 273 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 274 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 275 | <td class='online-navigation'><a rel="index" title="Index" |
| 276 | href="genindex.html"><img src='../icons/index.png' |
| 277 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 278 | </tr></table> |
| 279 | <div class='online-navigation'> |
| 280 | <b class="navlabel">Previous:</b> |
| 281 | <a class="sectref" rel="prev" href="module-cd.html">20.3 cd </A> |
| 282 | <b class="navlabel">Up:</b> |
| 283 | <a class="sectref" rel="parent" href="module-cd.html">20.3 cd </A> |
| 284 | <b class="navlabel">Next:</b> |
| 285 | <a class="sectref" rel="next" href="cd-parser-objects.html">20.3.2 Parser Objects</A> |
| 286 | </div> |
| 287 | </div> |
| 288 | <hr /> |
| 289 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 290 | </DIV> |
| 291 | <!--End of Navigation Panel--> |
| 292 | <ADDRESS> |
| 293 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 294 | </ADDRESS> |
| 295 | </BODY> |
| 296 | </HTML> |