pub struct AudioSink { /* private fields */ }
Expand description
Asset controlling the playback of a sound
// Execution of this system should be controlled by a state or input,
// otherwise it would just toggle between play and pause every frame.
fn pause(
audio_sinks: Res<Assets<AudioSink>>,
music_controller: Local<Handle<AudioSink>>,
) {
if let Some(sink) = audio_sinks.get(&*music_controller) {
if sink.is_paused() {
sink.play()
} else {
sink.pause()
}
}
}
Implementations§
§impl AudioSink
impl AudioSink
pub fn volume(&self) -> f32
pub fn volume(&self) -> f32
Gets the volume of the sound.
The value 1.0
is the “normal” volume (unfiltered input). Any value other than 1.0
will multiply each sample by this value.
pub fn set_volume(&self, volume: f32)
pub fn set_volume(&self, volume: f32)
Changes the volume of the sound.
The value 1.0
is the “normal” volume (unfiltered input). Any value other than 1.0
will multiply each sample by this value.
pub fn speed(&self) -> f32
pub fn speed(&self) -> f32
Gets the speed of the sound.
The value 1.0
is the “normal” speed (unfiltered input). Any value other than 1.0
will change the play speed of the sound.
pub fn set_speed(&self, speed: f32)
pub fn set_speed(&self, speed: f32)
Changes the speed of the sound.
The value 1.0
is the “normal” speed (unfiltered input). Any value other than 1.0
will change the play speed of the sound.
pub fn play(&self)
pub fn play(&self)
Resumes playback of a paused sink.
No effect if not paused.
pub fn pause(&self)
pub fn pause(&self)
Pauses playback of this sink.
No effect if already paused.
A paused sink can be resumed with play
.
pub fn toggle(&self)
pub fn toggle(&self)
Toggles the playback of this sink.
Will pause if playing, and will be resumed if paused.
pub fn stop(&self)
pub fn stop(&self)
Stops the sink.
It won’t be possible to restart it afterwards.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for AudioSink
impl Send for AudioSink
impl Sync for AudioSink
impl Unpin for AudioSink
impl UnwindSafe for AudioSink
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist. Read more§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more