diff --git a/src/music_box.rs b/src/music_box.rs index 95bc4ca6742ec13695eb0931cc32b6ea2207a305..ec023cd4fbaa131093c639eca2f25c602968ab92 100644 --- a/src/music_box.rs +++ b/src/music_box.rs @@ -263,6 +263,25 @@ impl<'w, 's, T: SuppliesAudio> MusicBox<'w, 's, T> { TrackType::Missing => None, } } + + /// Play a new sound effect on the SFX channel in a loop. Ideal for ambient spatial sounds + /// like a crackling fireplace + /// + /// # Returns + /// + /// A handle for the newly started audio instance, or `None` if the track was not found + pub fn start_looped_sfx<Name: ToString>( + &mut self, + name: Name, + ) -> Option<Handle<AudioInstance>> { + match self.map_tracks(name) { + TrackType::WithIntro(_, track) | TrackType::Single(track) => { + let instance = self.channels.sfx_channel.play(track).looped().handle(); + Some(instance) + } + TrackType::Missing => None, + } + } /// Play a new sound effect on the UI SFX channel /// /// # Returns