Add helpers to play, pause, and stop sound sources.

This commit is contained in:
Nolan Darilek 2020-12-23 19:25:30 -06:00
parent aec72c3e57
commit acc004b2ef

View File

@ -143,6 +143,27 @@ impl Default for Sound {
} }
} }
} }
impl Sound {
pub fn play(&mut self) {
if let Some(source) = self.source.as_mut() {
source.play();
}
}
pub fn stop(&mut self) {
if let Some(source) = self.source.as_mut() {
source.stop();
}
}
pub fn pause(&mut self) {
if let Some(source) = self.source.as_mut() {
source.pause();
}
}
}
pub type Sounds = HashMap<String, Sound>; pub type Sounds = HashMap<String, Sound>;
#[derive(Default)] #[derive(Default)]