Sound class

implements Disposable

Sound that is played in DX Engine.

All sounds require a sound asset id and need to be fully loaded before they can be played.


dispose(self) -> None

Inherited from Disposable.

Disposes this object, effectively turning this into an unmanaged resource.

is_playing(self) -> bool

Returns true if the sound is currently playing

static load(id: str) -> Sound

Loads a sound via the provided sound id.

static load(id: str, callback: Callable[[t: Sound], None]) -> Sound

Loads a sound via the provided sound id.

pause(self) -> None

Pauses playback of this Sound.

play(self) -> None

Plays this Sound.

play(self, on_finish: Callable[[], None]) -> None

Plays this Sound.

play(self, looping: bool) -> None

Plays this Sound.

static play_one_shot(sound: Sound, volume: float) -> None

Plays a oneshot sound based on the provided, loaded Sound.

stop(self) -> None

Stops playback of this Sound.

static stop_all() -> None

Stops all sounds that are currently playing.

static stop_by_id(sound_ids: Iterable) -> None

Stops all sounds by their sound asset id.

static stop_by_id(sound_id: str) -> None

Stops a sound by its sound asset id.


current_position float

Defines the track position of this Sound.

readonly duration float

Returns duration of this Sound in seconds.

volume float

Defines the normalized volume of this Sound. Volume value is clamped to range [0,1]