AudioStream

A streaming audio object for single-instance playback of large audio files.

Constructor

  • AudioStream(
        file_path: str,
        volume: SupportsFloat = 1.0
    ) AudioStream

A streaming audio object for single-instance playback of large audio files.

Properties


NameDescriptionType
current_timeThe current playback time position in seconds.float
volumeThe volume level of the audio stream.float

Methods


Pause

pause() None

Pause the audio stream playback.

The stream position is preserved and can be resumed with resume().

Play

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

Play the audio stream with optional fade-in time, loop setting, and start position.

Starts playback from the specified time position. If the stream is already playing, it will restart from the specified position.

Args

  • fade_in_ms : Fade-in duration in milliseconds. Defaults to 0.
  • loop : Whether to loop the audio continuously. Defaults to False.
  • start_time_seconds : Time position in seconds to start playback from. Defaults to 0.0.

Resume

resume() None

Resume paused audio stream playback.

Continues playback from the current stream position.

Rewind

rewind() None

Rewind the audio stream to the beginning.

Sets the playback position back to the start of the audio file. Does not affect the current play state (playing/paused).

Seek

seek(time_seconds: SupportsFloat) None

Seek to a specific time position in the audio stream.

Sets the playback position to the specified time in seconds. Does not affect the current play state (playing/paused).

Args

  • time_seconds : The time position in seconds to seek to.

Set Looping

set_looping(loop: bool) None

Set whether the audio stream loops continuously.

Args

  • loop : True to enable looping, False to disable.

Stop

stop(fade_out_ms: SupportsInt = 0) None

Stop the audio stream playback.

Args

  • fade_out_ms : Fade-out duration in milliseconds. If 0, stops immediately. If > 0, fades out over the specified duration. Defaults to 0.