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<Decibels>) -> TweenCommand<'_, FadeIn>
fn set_volume(&self, volume: impl Into<Decibels>) -> TweenCommand<'_, FadeIn>
Set the volume in Decibels
fn my_system(audio: Res<Audio>) {
audio.set_volume(-6.);
}Source§fn set_panning(&self, panning: f32) -> TweenCommand<'_, FadeIn>
fn set_panning(&self, panning: f32) -> TweenCommand<'_, FadeIn>
Set panning
The default value is 0.0 Values up to 1.0 pan to the right Values down to -1.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> Component for AudioChannel<T>
impl<T> Component for AudioChannel<T>
Source§const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::SparseSet
const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::SparseSet
A constant indicating the storage type used for this component.
Source§type Mutability = Mutable
type Mutability = Mutable
A marker type to assist Bevy with determining if this component is
mutable, or immutable. Mutable components will have
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Registers required components. Read more
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
Returns
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
Maps the entities on this component using the given
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§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> !Unpin for AudioChannel<T>
impl<T> !UnwindSafe for AudioChannel<T>
impl<T> Send for AudioChannel<T>where
T: Send,
impl<T> Sync for AudioChannel<T>where
T: Sync,
impl<T> UnsafeUnpin 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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<T> ConditionalSend for Twhere
T: Send,
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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&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> DowncastSend for T
impl<T> DowncastSend for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Moves the components out of the bundle. Read more
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Applies the after-effects of spawning this bundle. Read more
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.