Audio
A decoded audio object that supports multiple simultaneous playbacks.
Constructor
-
Audio(
file_path: str,
volume: SupportsFloat = 1.0
) → Audio
A decoded audio object that supports multiple simultaneous playbacks.
Properties
| Name | Description | Type |
|---|---|---|
volume | The volume level for new and existing playbacks. | float |
Methods
Play
play(
fade_in_ms: SupportsInt = 0,
loop: bool = False
) → NonePlay the audio with optional fade-in time and loop setting.
Creates a new voice for playback, allowing multiple simultaneous plays of the same audio. Each play instance is independent and can have different fade and loop settings.
Args
fade_in_ms: Fade-in duration in milliseconds. Defaults to 0.loop: Whether to loop the audio continuously. Defaults to False.
Raises
RuntimeError: If audio playback initialization fails.
Stop
stop(fade_out_ms: SupportsInt = 0) → NoneStop all active playbacks of this audio.
Stops all currently playing voices associated with this Audio object. If a fade-out time is specified, all voices will fade out over that duration before stopping.
Args
fade_out_ms: Fade-out duration in milliseconds. Defaults to 0.