Is it possible to write a Audio CD Player by using python only?

Gerrit Holl gerrit at nl.linux.org
Thu Jun 26 09:51:15 EDT 2003


MiLF wrote:
> Is it possible to write a Audio CD Player by using python only?

What do you mean with 'Python only'? Do you mean without 3rd-party libraries?

If you don't mean "without 3rd-party libraries", it's possible with te pygame
library:

http://pygame.org/docs/ref/CD.html#play

15:46:12:2:gerrit at stopcontact:~$ python
Python 2.3b1+ (#3, Jun 19 2003, 10:34:37)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  0 >>> import pygame
  1 >>> pygame.init()
mcop warning: user defined signal handler found for SIG_PIPE, overriding
(6, 0)
  3 >>> cd = pygame.cdrom.CD(0) # first cd drive
  4 >>> cd.init()
  5 >>> cd.eject() # remove the CD
  6 >>> cd.get_all() # do it back in before you do this
((1, 2.0, 348.48000000000002, 346.48000000000002), (1, 348.48000000000002, 699.56000000000006, 351.07999999999998), (1, 699.55999999999995, 1390.9199999999998, 691.36000000000001), (1, 1390.9200000000001, 1936.5333333333333, 545.61333333333334), (1, 1936.5333333333333, 2951.6666666666665, 1015.1333333333333), (1, 2951.6666666666665, 4128.8400000000001, 1177.1733333333334), (1, 4128.8400000000001, 4721.1999999999998, 592.36000000000001))
  8 >>> cd.get_track_length(1)
351.07999999999998
  9 >>> cd.get_track_length(2)
691.36000000000001
 10 >>> cd.play(2) # playing...

Pygame is a cross-platform library, so this code should work on Windows and
Linux (I'm not sure whether Pygame works for the Mac, though). 

yours,
Gerrit.

-- 
279. If any one by a male or female slave, and a third party claim it,
the seller is liable for the claim.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list