1use crate::Error;
2use crate::audio_codecs::AudioCodec;
3use crate::cpal_abstraction::{Device, SampleType, SamplesTrait};
4use crate::samples_player::SamplesPlayerTrait;
5use crate::errors::PlayError;
6
7pub trait AudioFileTrait {
9 fn get_samples(&self) -> Error<Box<dyn SamplesTrait>>;
11
12 fn make_player(&self, is_exact: bool) -> Error<Box<dyn SamplesPlayerTrait>>;
14
15 fn play(&self, device: Device, is_exact: bool) -> Error<Box<dyn SamplesPlayerTrait>>;
17
18 fn play_on_default_output(&self, is_exact: bool) -> Error<Box<dyn SamplesPlayerTrait>> {
20 let device = match Device::default_output() {
21 Some(d) => d,
22 None => return Err(PlayError::DeviceDoesNotExist { name: "default".to_string() })
23 };
24
25 self.play(device, is_exact)
26 }
27
28 fn metadata(&self) -> Box<dyn AudioMetadataTrait>;
30}
31
32pub trait AudioMetadataTrait {
34 fn file_path(&self) -> Option<String>;
36 fn audio_codec(&self) -> AudioCodec;
38 fn channels(&self) -> u32;
40 fn sample_rate(&self) -> u32;
42 fn sample_type(&self) -> Option<SampleType>;
44}