World > Sound#
- class miniworlds.worlds.manager.sound_manager.SoundManager(app)[Quellcode]#
Public Methods:
__init__
(app)play
(path[, volume])Plays a sound from the given path.
register
(path)Registers a sound for later use.
is_registered
(path)Checks if a sound is already registered.
stop
(path)Stops a playing sound.
is_playing
(path)Checks if the given sound is currently playing.
- is_playing(path)[Quellcode]#
Checks if the given sound is currently playing.
- Rückgabetyp:
- Parameter:
path – The path to the sound.
- Rückgabe:
True if the sound is currently playing, False otherwise.
- Rückgabetyp:
- Verursacht:
ValueError – If path is empty.
Example
- if world.sound.is_playing(„sounds/explosion.wav“):
world.sound.stop(„sounds/explosion.wav“)
- is_registered(path)[Quellcode]#
Checks if a sound is already registered.
- Rückgabetyp:
- Parameter:
path – The path to the sound.
- Rückgabe:
True if the sound is already registered, False otherwise.
- Rückgabetyp:
- Verursacht:
ValueError – If path is empty.
Example
- if not world.sound.is_registered(„sounds/explosion.wav“):
world.sound.register(„sounds/explosion.wav“)
- play(path, volume=100)[Quellcode]#
Plays a sound from the given path.
- Rückgabetyp:
- Parameter:
path – The path to the sound.
volume – Volume to play the sound (0 min, 100 max).
- Verursacht:
ValueError – If path is empty or volume is out of range.
Example
world.sound.play(„sounds/explosion.wav“, volume=80)
- register(path)[Quellcode]#
Registers a sound for later use.
- Rückgabetyp:
- Parameter:
path – The path to the sound.
- Verursacht:
ValueError – If path is empty.
Example
world.sound.register(„sounds/explosion.wav“)
- stop(path)[Quellcode]#
Stops a playing sound.
- Rückgabetyp:
- Parameter:
path – The path to the sound to stop.
- Verursacht:
ValueError – If path is empty.
Example
world.sound.stop(„sounds/explosion.wav“)