mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			104 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
	
		
			4.2 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| Interface to CD-ROM player.
 | |
| 
 | |
| This module implements an interface to the built-in cd module.  The
 | |
| intention is to provide a more user-friendly interface than the
 | |
| built-in module.
 | |
| 
 | |
| The module defines a class Readcd with several methods.  The
 | |
| initialization of the class will try to open the CD player.  This
 | |
| means that initialization will fail if the CD player is already in
 | |
| use.  A RuntimeError will be raised by the cd module in that case.
 | |
| 
 | |
| The way to work with this module is as follows.  The user specifies
 | |
| the parts of the CD that are to be read and he specifies callback
 | |
| functions which are to be called by the system.  At some point he can
 | |
| tell the system to play.  The specified parts of the CD will then be
 | |
| read and the callbacks will be called.
 | |
| 
 | |
| Initialization.
 | |
| ===============
 | |
| 
 | |
| r = readcd.Readcd([cd-player [, mode]])
 | |
| 
 | |
| The optional arguments are the name of the CD device and the mode.
 | |
| When "mode" is not specified, it defaults to 'r' (which is the only
 | |
| possible value); when "cd-player" also isn't specified, it defaults
 | |
| to "None" which indicates the default CD player.
 | |
| 
 | |
| Methods.
 | |
| ========
 | |
| 
 | |
| eject() -- Eject the CD from the player.
 | |
| 
 | |
| reset() -- Reset the list of data stretches to be played.
 | |
| 
 | |
| appendtrack(track) -- Append the specified track to the list of music
 | |
| stretches.
 | |
| 
 | |
| appendstretch(first, last) -- Append the stretch from "first" to "last"
 | |
| to the list of music stretches.  Both "first" and "last" can be in one
 | |
| of four forms.  "None": for "first", the beginning of the CD, for
 | |
| "last" the end of the CD; a single integer: a track number--playing
 | |
| starts at the beginning of the track or ends at the end of the
 | |
| specified track; a three-tuple: the absolute time from the start of
 | |
| the CD in minutes, seconds, frames; a four-tuple: track number and
 | |
| relative time within the track in minutes, seconds, frames.
 | |
| 
 | |
| settracks(tracklist) -- The argument is a list of integers.  The list
 | |
| of stretches is set to argument list.  The old list is discarded.
 | |
| 
 | |
| setcallback(type, func, arg) -- Set a callback function for "type".
 | |
| The function will be called as func(arg, type, data) where "arg" is
 | |
| the third argument of setcallback, "type" is the type of callback,
 | |
| "data" is type-dependent data.  See the CDsetcallback(3) manual page
 | |
| for more information.  The possible "type" arguments are defined in
 | |
| the CD module.
 | |
| 
 | |
| removecallback(type) -- Remove the callback for "type".
 | |
| 
 | |
| gettrackinfo([tracklist]) -- Return a list of tuples.  Each tuple
 | |
| consists of start and length information of a track.  The start and
 | |
| length information consist of three-tuples with minutes, seconds and
 | |
| frames.  The optional tracklist argument gives a list of interesting
 | |
| track numbers.  If no tracklist is specified, information about all
 | |
| tracks is returned.
 | |
| 
 | |
| getstatus() -- Return the status information of the CD.
 | |
| 
 | |
| play() -- Play the preprogrammed stretches of music from the CD.  When
 | |
| nothing was programmed, the whole CD is played.
 | |
| 
 | |
| Specifying stretches.
 | |
| =====================
 | |
| 
 | |
| There are three methods available to specify a stretch of music to be
 | |
| played.  The easiest way is to use "settracklist(tracklist)" with which
 | |
| a list of tracks can be specified.  "settracklist(tracklist)" is
 | |
| equivalent to the sequence
 | |
| 	reset()
 | |
| 	for track in tracklist:
 | |
| 		appendtrack(track)
 | |
| 
 | |
| The next method is "appendtrack(track)" with which a whole track can be
 | |
| added to the list of music to be played.  "appendtrack(track)" is
 | |
| equivalent to "appendstretch(track, track)".
 | |
| 
 | |
| The most complete method is "appendstretch(first, last)".  Using this
 | |
| method, it is possible to specify any stretch of music.
 | |
| 
 | |
| When two consecutive tracks are played, it is possible to choose
 | |
| whether the pause that may be between the tracks is played as well or
 | |
| whether the pause should be skipped.  When the end of a stretch is
 | |
| specified using a track number and the next stretch starts at the
 | |
| beginning of the following track and that was also specified using the
 | |
| track number (that is, both were specified as integers, not as tuples),
 | |
| the pause is played.  When either value was specified using absolute
 | |
| time or track-relative time (that is, as three-tuple or as
 | |
| four-tuple), the pause will not be played.
 | |
| 
 | |
| Errors.
 | |
| =======
 | |
| 
 | |
| When an error occurs, an exception will be raised.  Depending on where
 | |
| the error occurs, the exception may either be "readcd.Error" or
 | |
| "RuntimeError".
 | 
