Struct bones_framework::audio::audio_center::AudioCenter
source · pub struct AudioCenter { /* private fields */ }
Expand description
A resource that can be used to control game audios.
Implementations§
source§impl AudioCenter
impl AudioCenter
sourcepub fn push_event(&mut self, event: AudioEvent)
pub fn push_event(&mut self, event: AudioEvent)
Push an audio event to the queue for later processing.
sourcepub fn music_state(&self) -> Option<PlaybackState>
pub fn music_state(&self) -> Option<PlaybackState>
Get the playback state of the current music.
sourcepub fn play_sound(&mut self, sound_source: Handle<AudioSource>, volume: f64)
pub fn play_sound(&mut self, sound_source: Handle<AudioSource>, volume: f64)
Play a sound. These are usually short audios that indicate something happened in game, e.g. a player jump, an explosion, etc. Volume is scaled by both main_volume_scale, and effects_volume_scale.
sourcepub fn play_music(
&mut self,
sound_source: Handle<AudioSource>,
volume: f64,
loop_music: bool,
)
pub fn play_music( &mut self, sound_source: Handle<AudioSource>, volume: f64, loop_music: bool, )
Plays music, forcibly stopping any current music. Volume is scaled by both main_volume_scale and music_volume_scale.
sourcepub fn play_music_advanced(
&mut self,
sound_source: Handle<AudioSource>,
volume: f64,
loop_music: bool,
reverse: bool,
start_position: f64,
playback_rate: f64,
skip_restart: bool,
)
pub fn play_music_advanced( &mut self, sound_source: Handle<AudioSource>, volume: f64, loop_music: bool, reverse: bool, start_position: f64, playback_rate: f64, skip_restart: bool, )
Plays music with advanced settings. Volume is scaled by both main_volume_scale and music_volume_scale.
§Parameters
sound_source
- The handle for the audio source to playvolume
- The volume to play the music at (0.0 to 1.0)loop_music
- Whether the music should loop indefinitelyreverse
- Whether to play the audio in reversestart_position
- The position in seconds to start playback fromplayback_rate
- The playback rate (1.0 is normal speed, 0.5 is half speed, 2.0 is double speed)skip_restart
- If true, won’t restart the music if it’s already playing the same track
sourcepub fn play_music_custom(
&mut self,
sound_source: Handle<AudioSource>,
sound_settings: StaticSoundSettings,
skip_restart: bool,
)
pub fn play_music_custom( &mut self, sound_source: Handle<AudioSource>, sound_settings: StaticSoundSettings, skip_restart: bool, )
Plays music with custom StaticSoundSettings. Volume is scaled by both main_volume_scale and music_volume_scale.
sourcepub fn set_main_volume_scale(&mut self, main: f32)
pub fn set_main_volume_scale(&mut self, main: f32)
Sets the volume scale for main audio within the range of 0.0 to 1.0. The main volume scale impacts all other volume scales.
sourcepub fn set_music_volume_scale(&mut self, music: f32)
pub fn set_music_volume_scale(&mut self, music: f32)
Sets the volume scale for music within the range of 0.0 to 1.0.
sourcepub fn set_effects_volume_scale(&mut self, effects: f32)
pub fn set_effects_volume_scale(&mut self, effects: f32)
Sets the volume scale for effects within the range of 0.0 to 1.0.
sourcepub fn set_volume_scales(&mut self, main: f32, music: f32, effects: f32)
pub fn set_volume_scales(&mut self, main: f32, music: f32, effects: f32)
Sets the volume scales for main, music, and effects within the range of 0.0 to 1.0.
sourcepub fn main_volume_scale(&self) -> f32
pub fn main_volume_scale(&self) -> f32
Returns the main volume scale (which impacts all other volume scales).
sourcepub fn music_volume_scale(&self) -> f32
pub fn music_volume_scale(&self) -> f32
Returns the music volume scale.
sourcepub fn effects_volume_scale(&self) -> f32
pub fn effects_volume_scale(&self) -> f32
Returns the volume scale for sound effects.
sourcepub fn music_fade_duration(&self) -> Duration
pub fn music_fade_duration(&self) -> Duration
Returns the duration for music fade out.
sourcepub fn set_music_fade_duration(&mut self, duration: Duration)
pub fn set_music_fade_duration(&mut self, duration: Duration)
Sets the duration for music fade out.
sourcepub fn sounds_fade_duration(&self) -> Duration
pub fn sounds_fade_duration(&self) -> Duration
Returns the duration for audio fade out.
sourcepub fn set_sounds_fade_duration(&mut self, duration: Duration)
pub fn set_sounds_fade_duration(&mut self, duration: Duration)
Sets the duration for audio fade out.
sourcepub fn stop_music(&mut self, fade_out: bool)
pub fn stop_music(&mut self, fade_out: bool)
Stops the currently playing music
fade_out
- If true, fades out the music using the Audio Center’s music fade duration. If false, stops the sounds instantly.
sourcepub fn stop_all_sounds(&mut self, fade_out: bool)
pub fn stop_all_sounds(&mut self, fade_out: bool)
Stops all currently playing sounds.
fade_out
- If true, fades out the sounds using the Audio Center’s sounds fade duration. If false, stops the sounds instantly.
Trait Implementations§
source§impl Default for AudioCenter
impl Default for AudioCenter
source§impl HasSchema for AudioCenter
impl HasSchema for AudioCenter
source§fn register_schema()
fn register_schema()
source§fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
source§fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
source§fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
source§fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
source§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
T
to a SchemaRef
source§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
T
to a SchemaRefMut
Auto Trait Implementations§
impl Freeze for AudioCenter
impl !RefUnwindSafe for AudioCenter
impl Send for AudioCenter
impl Sync for AudioCenter
impl Unpin for AudioCenter
impl !UnwindSafe for AudioCenter
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere
T: Default,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.