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
| Name | Description | Type |
|---|---|---|
current_time | The current playback time position in seconds. | float |
volume | The volume level of the audio stream. | float |
Methods
Pause
pause() → NonePause 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
) → NonePlay 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() → NoneResume paused audio stream playback.
Continues playback from the current stream position.
Rewind
rewind() → NoneRewind 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) → NoneSeek 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) → NoneSet whether the audio stream loops continuously.
Args
loop: True to enable looping, False to disable.
Stop
stop(fade_out_ms: SupportsInt = 0) → NoneStop 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.