pub struct AudioManager { /* private fields */ }Expand description
The audio manager controls playback, volume, and spatial audio.
§Example
let mut audio = AudioManager::new();
audio.load("jump", "sounds/jump.ogg");
audio.load("bgm", "music/theme.ogg");
// Play a sound effect
audio.play("jump");
// Play music with fade-in
audio.play_music("bgm", Fade::In(2.0));
// Update spatial audio
audio.update_listener_position(listener_pos);
audio.update(dt);Implementations§
Source§impl AudioManager
impl AudioManager
Sourcepub fn load(&mut self, name: &str, _path: &str) -> Result<(), String>
pub fn load(&mut self, name: &str, _path: &str) -> Result<(), String>
Register a sound (in a real impl, this loads the audio file).
Sourcepub fn load_with_config(&mut self, sound: Sound)
pub fn load_with_config(&mut self, sound: Sound)
Register a sound with custom configuration.
Sourcepub fn play_on_channel(&mut self, name: &str, channel: AudioChannel)
pub fn play_on_channel(&mut self, name: &str, channel: AudioChannel)
Play a sound on a specific channel.
Sourcepub fn play_music(&mut self, name: &str, fade: Fade)
pub fn play_music(&mut self, name: &str, fade: Fade)
Play music with optional fade.
Sourcepub fn stop_channel(&mut self, channel: AudioChannel)
pub fn stop_channel(&mut self, channel: AudioChannel)
Stop all instances on a channel.
Sourcepub fn set_master_volume(&mut self, volume: f32)
pub fn set_master_volume(&mut self, volume: f32)
Set the master volume (0.0–1.0).
Sourcepub fn set_channel_volume(&mut self, channel: AudioChannel, volume: f32)
pub fn set_channel_volume(&mut self, channel: AudioChannel, volume: f32)
Set a channel’s volume (0.0–1.0).
Sourcepub fn set_listener_position(&mut self, pos: Vec2)
pub fn set_listener_position(&mut self, pos: Vec2)
Set the listener position for spatial audio.
Sourcepub fn resume_all(&mut self)
pub fn resume_all(&mut self)
Resume all audio.
Sourcepub fn is_playing(&self, name: &str) -> bool
pub fn is_playing(&self, name: &str) -> bool
Check if a named sound is currently playing.
Sourcepub fn playing_count(&self) -> usize
pub fn playing_count(&self) -> usize
Number of currently playing instances.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AudioManager
impl RefUnwindSafe for AudioManager
impl Send for AudioManager
impl Sync for AudioManager
impl Unpin for AudioManager
impl UnsafeUnpin for AudioManager
impl UnwindSafe for AudioManager
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