/Lib/plat-irix6/readcd.doc

http://unladen-swallow.googlecode.com/ · Unknown · 104 lines · 80 code · 24 blank · 0 comment · 0 complexity · 8d053d79488682c0b1187a54c8573665 MD5 · raw file

  1. Interface to CD-ROM player.
  2. This module implements an interface to the built-in cd module. The
  3. intention is to provide a more user-friendly interface than the
  4. built-in module.
  5. The module defines a class Readcd with several methods. The
  6. initialization of the class will try to open the CD player. This
  7. means that initialization will fail if the CD player is already in
  8. use. A RuntimeError will be raised by the cd module in that case.
  9. The way to work with this module is as follows. The user specifies
  10. the parts of the CD that are to be read and he specifies callback
  11. functions which are to be called by the system. At some point he can
  12. tell the system to play. The specified parts of the CD will then be
  13. read and the callbacks will be called.
  14. Initialization.
  15. ===============
  16. r = readcd.Readcd([cd-player [, mode]])
  17. The optional arguments are the name of the CD device and the mode.
  18. When "mode" is not specified, it defaults to 'r' (which is the only
  19. possible value); when "cd-player" also isn't specified, it defaults
  20. to "None" which indicates the default CD player.
  21. Methods.
  22. ========
  23. eject() -- Eject the CD from the player.
  24. reset() -- Reset the list of data stretches to be played.
  25. appendtrack(track) -- Append the specified track to the list of music
  26. stretches.
  27. appendstretch(first, last) -- Append the stretch from "first" to "last"
  28. to the list of music stretches. Both "first" and "last" can be in one
  29. of four forms. "None": for "first", the beginning of the CD, for
  30. "last" the end of the CD; a single integer: a track number--playing
  31. starts at the beginning of the track or ends at the end of the
  32. specified track; a three-tuple: the absolute time from the start of
  33. the CD in minutes, seconds, frames; a four-tuple: track number and
  34. relative time within the track in minutes, seconds, frames.
  35. settracks(tracklist) -- The argument is a list of integers. The list
  36. of stretches is set to argument list. The old list is discarded.
  37. setcallback(type, func, arg) -- Set a callback function for "type".
  38. The function will be called as func(arg, type, data) where "arg" is
  39. the third argument of setcallback, "type" is the type of callback,
  40. "data" is type-dependent data. See the CDsetcallback(3) manual page
  41. for more information. The possible "type" arguments are defined in
  42. the CD module.
  43. removecallback(type) -- Remove the callback for "type".
  44. gettrackinfo([tracklist]) -- Return a list of tuples. Each tuple
  45. consists of start and length information of a track. The start and
  46. length information consist of three-tuples with minutes, seconds and
  47. frames. The optional tracklist argument gives a list of interesting
  48. track numbers. If no tracklist is specified, information about all
  49. tracks is returned.
  50. getstatus() -- Return the status information of the CD.
  51. play() -- Play the preprogrammed stretches of music from the CD. When
  52. nothing was programmed, the whole CD is played.
  53. Specifying stretches.
  54. =====================
  55. There are three methods available to specify a stretch of music to be
  56. played. The easiest way is to use "settracklist(tracklist)" with which
  57. a list of tracks can be specified. "settracklist(tracklist)" is
  58. equivalent to the sequence
  59. reset()
  60. for track in tracklist:
  61. appendtrack(track)
  62. The next method is "appendtrack(track)" with which a whole track can be
  63. added to the list of music to be played. "appendtrack(track)" is
  64. equivalent to "appendstretch(track, track)".
  65. The most complete method is "appendstretch(first, last)". Using this
  66. method, it is possible to specify any stretch of music.
  67. When two consecutive tracks are played, it is possible to choose
  68. whether the pause that may be between the tracks is played as well or
  69. whether the pause should be skipped. When the end of a stretch is
  70. specified using a track number and the next stretch starts at the
  71. beginning of the following track and that was also specified using the
  72. track number (that is, both were specified as integers, not as tuples),
  73. the pause is played. When either value was specified using absolute
  74. time or track-relative time (that is, as three-tuple or as
  75. four-tuple), the pause will not be played.
  76. Errors.
  77. =======
  78. When an error occurs, an exception will be raised. Depending on where
  79. the error occurs, the exception may either be "readcd.Error" or
  80. "RuntimeError".