pub struct AudioChannel<T> { /* private fields */ }
Expand description
Channel to play and control audio
Add your own channels via add_audio_channel
.
By default, there is only the AudioChannel<MainTrack>
channel.
Trait Implementations§
Source§impl<T> AudioControl for AudioChannel<T>
impl<T> AudioControl for AudioChannel<T>
Source§fn play(&self, audio_source: Handle<AudioSource>) -> PlayAudioCommand<'_>
fn play(&self, audio_source: Handle<AudioSource>) -> PlayAudioCommand<'_>
Play audio
fn my_system(asset_server: Res<AssetServer>, audio: Res<Audio>) {
audio.play(asset_server.load("audio.mp3"));
}
Source§fn stop(&self) -> TweenCommand<'_, FadeOut>
fn stop(&self) -> TweenCommand<'_, FadeOut>
Stop all audio
fn my_system(audio: Res<Audio>) {
audio.stop();
}
Source§fn pause(&self) -> TweenCommand<'_, FadeOut>
fn pause(&self) -> TweenCommand<'_, FadeOut>
Pause all audio
fn my_system(audio: Res<Audio>) {
audio.pause();
}
Source§fn resume(&self) -> TweenCommand<'_, FadeIn>
fn resume(&self) -> TweenCommand<'_, FadeIn>
Resume all audio
fn my_system(audio: Res<Audio>) {
audio.resume();
}
Source§fn set_volume(&self, volume: impl Into<Volume>) -> TweenCommand<'_, FadeIn>
fn set_volume(&self, volume: impl Into<Volume>) -> TweenCommand<'_, FadeIn>
Set the volume
The default value is 1.
fn my_system(audio: Res<Audio>) {
audio.set_volume(0.5);
}
Source§fn set_panning(&self, panning: f64) -> TweenCommand<'_, FadeIn>
fn set_panning(&self, panning: f64) -> TweenCommand<'_, FadeIn>
Set panning
The default value is 0.5 Values up to 1 pan to the right Values down to 0 pan to the left
fn my_system(audio: Res<Audio>) {
audio.set_panning(0.9);
}
Source§fn set_playback_rate(&self, playback_rate: f64) -> TweenCommand<'_, FadeIn>
fn set_playback_rate(&self, playback_rate: f64) -> TweenCommand<'_, FadeIn>
Set playback rate
The default value is 1
fn my_system(audio: Res<Audio>) {
audio.set_playback_rate(2.0);
}
Source§fn state(&self, instance_handle: &Handle<AudioInstance>) -> PlaybackState
fn state(&self, instance_handle: &Handle<AudioInstance>) -> PlaybackState
Get state for a playback instance.
Source§fn is_playing_sound(&self) -> bool
fn is_playing_sound(&self) -> bool
Returns true
if there is any sound in this channel that is in the state Playing
, Pausing
, or Stopping
If there are only Stopped
, Paused
, or Queued
sounds, the method will return false
.
The same result is returned if there are no sounds in the channel at all.
Source§impl<T> Default for AudioChannel<T>
impl<T> Default for AudioChannel<T>
impl<T> Resource for AudioChannel<T>
Auto Trait Implementations§
impl<T> !Freeze for AudioChannel<T>
impl<T> !RefUnwindSafe for AudioChannel<T>
impl<T> Send for AudioChannel<T>where
T: Send,
impl<T> Sync for AudioChannel<T>where
T: Sync,
impl<T> Unpin for AudioChannel<T>where
T: Unpin,
impl<T> !UnwindSafe for AudioChannel<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more