From acc004b2eff3e1728dcc61a334608450140766e5 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 23 Dec 2020 19:25:30 -0600 Subject: [PATCH] Add helpers to play, pause, and stop sound sources. --- src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bf3846a..5116e37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; #[derive(Default)]