Open topic with navigation
<viz>.playSound
Play a sound
<viz>.playSound( |
|
filename |
flag = PLAY |
) |
|
filename
Name of file containing audio in a supported format
flag = PLAY
Specifies any special play modes:
viz.PLAY | Play the sound from the beginning to end once |
viz.LOOP | Play the sound from beginning to end on a continuous loop |
viz.STOP | Stop a playing sound |
viz.SOUND_PRELOAD | Preload the sound to prevent any delay when playing sound for first time |
Remarks
Use this method to play a sound file asynchronously through global sound mixer.
There might be a short delay between issuing the command and hearing the sound for the first time. To prevent the delay, you can preload the sound files by issuing the command with the viz.SOUND_PRELOAD flag. This essentially loads the sound file and immediately stops it.
Return Value
None
Example
# Play sound once
viz.playSound('boing!.wav')
# Loop sound
viz.playSound('boing!.wav',viz.LOOP)
# Stop sound
viz.playSound('boing!.wav',viz.STOP)
# Preload sound
viz.playSound('boing!.wav',viz.SOUND_PRELOAD)
See also