Pygame Tutorial
Selected Reading
- Pygame - Discussion
- Pygame - Useful Resources
- Pygame - Quick Guide
- Pygame - Errors and Exception
- Pygame - PyOpenGL
- Pygame - The Sprite Module
- Pygame - Access CDROM
- Pygame - Load cursor
- Pygame - Using Camera module
- Pygame - Playing Movie
- Pygame - Playing music
- Pygame - Mixer channels
- Pygame - Sound objects
- Pygame - Transforming Images
- Pygame - Use Text as Buttons
- Pygame - Moving Rectangular objects
- Pygame - Moving with mouse
- Pygame - Moving with Numeric pad keys
- Pygame - Moving an image
- Pygame - Displaying Text in Window
- Pygame - Loading image
- Pygame - Drawing shapes
- Pygame - Mouse events
- Pygame - Keyboard events
- Pygame - Event objects
- Pygame - Color object
- Pygame - Locals module
- Pygame - Display modes
- Pygame - Hello World
- Pygame - Overview
- Pygame - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Pygame - Access CDROM
Pygame - Access CDROM
The pygame pbrary has pygame.cdrom module that enables the program to manage playback from audio CDs and DVDs. We need to exppcitly initiapze this module for its use.
>>> import pygame >>> pygame.cdrom.init()
The module defines all important CD class to represent the CDROM device. The constructor requires ID of CDROM drive available, starting with 0.
>>> obj=pygame.cdrom.CD(0)
The CDROM object has access to following useful functions to control the playback.
init() | initiapze a cdrom drive for use |
quit() | uninitiapze a cdrom drive for use |
play() | start playing audio |
stop() | stop audio playback |
pause() | temporarily stop audio playback |
resume() | unpause audio playback |
eject() | eject or open the cdrom drive |
get_busy() | true if the drive is playing audio |
get_paused() | true if the drive is paused |
get_empty() | False if a cdrom is in the drive |
get_numtracks() | the number of tracks on the cdrom |
get_track_audio() | true if the cdrom track has audio data |
get_track_start() | start time of a cdrom track |
get_track_length() | length of a cdrom track |
First, initiapze the object.
>>> obj.init()
To find out how many tracks are present in the current CD −
>>> obj.get_numtracks() 8
To start playing the required track, give its number to play() function.
>>> obj.play(4)
To pause, resume and stop the playback, we can use relevant functions psted above.
Advertisements