Package rstem :: Package speaker :: Class Sound
[hide private]
[frames] | no frames]

Class Sound

source code

object --+
         |
        Sound
Known Subclasses:

Basic foreground or background sound from a file

Instance Methods [hide private]
 
__init__(self, filename, background=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
play(self, loops=0, wait=False)
Plays sound a certain number of times
source code
 
stop(self)
Stops playback of sound.
source code
int
get_volume(self)
Gets the volume of individual sound
source code
 
set_volume(self, value)
Sets the volume of given sound.
source code
boolean
is_playing(self)
Returns: True if sound is currently playing
source code
 
queue(self)
Queues sound to play after other queued sounds have finished playing.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, background=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • filename (string) - Relative path to sound file
  • background (boolean) - Whether to play the sound as background music or as a sound effect
Overrides: object.__init__

play(self, loops=0, wait=False)

source code 

Plays sound a certain number of times

Parameters:
  • loops (int) - number of loops to play the sound (-1 to play infinitly)
  • wait (boolean) - If true, blocks until playback is finished

get_volume(self)

source code 

Gets the volume of individual sound

Returns: int
volume (a value between 0-100)

set_volume(self, value)

source code 

Sets the volume of given sound.

Parameters:
  • value (int) - volume to set sound at (between 0-100)

is_playing(self)

source code 
Returns: boolean
True if sound is currently playing

queue(self)

source code 

Queues sound to play after other queued sounds have finished playing.

Raises:
  • ValueError - Sounds is not a background sound. (Only supports background music)