Struct SoundRef
pub struct SoundRef { /* private fields */ }Expand description
A sound a client mod started with play_local_sound, to follow and control: state, stop
and fade. Each handle names one play and is never reused. Once the sound has ended, been
stopped or been cleared (leaving or changing levels stops every sound), the handle is stale: it
reads SoundState::Stopped and its writes do nothing. It stays valid across a change of
output device, which keeps the sounds playing.
Dropping or overwriting the handle doesn’t stop the sound: keep a looping sound’s handle while it plays (stop it before starting another in its place), or nothing can stop it until the player leaves the level.
Implementations§
§impl SoundRef
impl SoundRef
pub fn state(self, host: &dyn ClientHost) -> Option<SoundState>
pub fn state(self, host: &dyn ClientHost) -> Option<SoundState>
Side: client.
Where a sound play_local_sound started is: waiting to start, playing, or over.
pub fn stop(self, host: &dyn ClientHost) -> bool
pub fn stop(self, host: &dyn ClientHost) -> bool
Side: client. Stops the sound for good: a waiting one never starts and a looping one never repeats.
pub fn fade(self, host: &dyn ClientHost, volume: f32, ticks: u32) -> bool
pub fn fade(self, host: &dyn ClientHost, volume: f32, ticks: u32) -> bool
Side: client. Fades the sound’s volume to a target over some unpaused ticks; a fade to 0 stops it at the end. While the game is paused the fade waits, and an interface or music sound keeps playing.