AudioStream

An audio stream that streams data from disk.

Constructor

AudioStream(file_path: str, volume: float = 1.0)

Parameters

  • file_path : Path to the audio file to stream.
  • volume : Initial volume level (0.0 to 1.0+). Defaults to 1.0.

Note:

Audio file formats supported are WAV, FLAC, and MP3.

Properties


NameDescriptionType
volumeThe volume of the audio stream, from 0.0-1.0, with values above 1.0 allowed for amplification.float
current_timeThe current playback time of the audio stream in seconds.float

Methods


Play

play(
    fade_in_ms: int = 0,
    loop: bool = false,
    start_time_seconds: float = 0.0
) None

Play the audio stream with optional fade-in, looping, and start time.

Parameters

  • fade_in_ms : The duration in milliseconds to fade in the audio.
  • loop : Whether to loop the audio stream.
  • start_time_seconds : The time in seconds to start playback from.

Stop

stop(fade_out_ms: int = 0) None

Stop the audio stream.

Parameters

  • fade_out_ms : The duration in milliseconds to fade out the audio.

Seek

seek(time_seconds: float) None

Seek to a specific time in the audio stream.

Parameters

  • time_seconds : The time in seconds to seek to.

Pause

pause() None

Pause the audio stream.

Resume

resume() None

Resume the audio stream.

Rewind

rewind() None

Rewind the audio stream.

Set Looping

setLooping() None

Set whether the audio stream should loop.