Skip to content
Snippets Groups Projects
Verified Commit 7a2e9a08 authored by Louis's avatar Louis :fire:
Browse files

Add convenience methods for working directly with handles

parent ae2eb221
No related branches found
No related tags found
No related merge requests found
......@@ -352,6 +352,43 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> {
self.settings.ui_volume = level;
}
/// Stop an audio instance handle from playing immediately
pub fn stop_handle(&mut self, handle: &Handle<AudioInstance>) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.stop(AudioTween::default());
}
}
/// Stop an audio instance handle from playing with a given tween
pub fn stop_handle_with_tween(&mut self, handle: &Handle<AudioInstance>, tween: AudioTween) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.stop(tween);
}
}
/// Pause an audio instance handle immediately, in a way that can be resumed later
pub fn pause_handle(&mut self, handle: &Handle<AudioInstance>) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.pause(AudioTween::default());
}
}
/// Pause an audio instance with a given tween in a way that can be resumed later
pub fn pause_handle_with_tween(&mut self, handle: &Handle<AudioInstance>, tween: AudioTween) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.pause(tween);
}
}
/// Stop an audio instance handle from playing immediately
pub fn resume_handle(&mut self, handle: &Handle<AudioInstance>) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.resume(AudioTween::default());
}
}
/// Stop an audio instance handle from playing with a given tween
pub fn resume_handle_with_tween(&mut self, handle: &Handle<AudioInstance>, tween: AudioTween) {
if let Some(instance) = self.audio_instances.get_mut(handle) {
instance.resume(tween);
}
}
fn map_tracks<Name: ToString>(&'w self, name: Name) -> TrackType<Handle<AudioSource>> {
match self.handles.resolve_track_name(name) {
TrackType::Single(name) => match self.handles.get_audio_track(name) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment