ez_audi/samples_player/
samples_player_trait.rs

1use crate::{Device, traits::AudioMetadataTrait, modifiers::ModifierTrait, errors::Error, PlayError};
2
3
4
5/// Trait that implements the functionality of the SamplesPlayer struct
6pub trait SamplesPlayerTrait {
7    /// Returns the metadata of the samples
8    fn metadata(&self) -> Box<dyn AudioMetadataTrait>;
9
10    /// Adds a modifier
11    fn add_modifier(&mut self, modifier: Box<dyn ModifierTrait>);
12
13    /// Clears all modifiers and their effects
14    fn clear_modifiers(&mut self);
15
16    /// Starts/Continues the playing
17    fn start(&self) -> Error<()>;
18
19    /// Stops the playing
20    fn stop(&self) -> Error<()>;
21
22    /// Starts playing on a device
23    fn play_on_device(&mut self, _device: Device) -> Error<()>;
24
25    /// Starts playing on the default device of the default host
26    fn play_on_default(&mut self) -> Error<()> {
27        let default_output = match Device::default_output() {
28            Some(o) => o,
29            None => return Err(PlayError::DeviceDoesNotExist { name : "default".to_string() }),
30        };
31
32        self.play_on_device(default_output)
33    }
34}