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


NameDescriptionType
volumeThe volume level for new and existing playbacks.float

Methods


Play

play(
    fade_in_ms: SupportsInt = 0,
    loop: bool = False
) None

Play 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) None

Stop 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.