aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio.rs')
-rw-r--r--src/audio.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio.rs b/src/audio.rs
index 4e26263..93eb8e6 100644
--- a/src/audio.rs
+++ b/src/audio.rs
@@ -18,6 +18,7 @@ pub struct AudioEngine {
18 is_playing: Arc<AtomicBool>, 18 is_playing: Arc<AtomicBool>,
19 current_track: Arc<Mutex<Option<std::path::PathBuf>>>, 19 current_track: Arc<Mutex<Option<std::path::PathBuf>>>,
20 track_ended: Arc<AtomicBool>, 20 track_ended: Arc<AtomicBool>,
21 volume: Arc<Mutex<f32>>,
21} 22}
22 23
23impl AudioEngine { 24impl AudioEngine {
@@ -48,6 +49,7 @@ impl AudioEngine {
48 is_playing, 49 is_playing,
49 current_track, 50 current_track,
50 track_ended, 51 track_ended,
52 volume,
51 } 53 }
52 } 54 }
53 55
@@ -75,6 +77,13 @@ impl AudioEngine {
75 let _ = self.command_tx.send(AudioCommand::SetVolume(volume)); 77 let _ = self.command_tx.send(AudioCommand::SetVolume(volume));
76 } 78 }
77 79
80 pub fn get_volume(&self) -> u8 {
81 self.volume
82 .lock()
83 .map(|v| (*v * 100.0) as u8)
84 .unwrap_or(100)
85 }
86
78 pub fn is_playing(&self) -> bool { 87 pub fn is_playing(&self) -> bool {
79 self.is_playing.load(Ordering::SeqCst) 88 self.is_playing.load(Ordering::SeqCst)
80 } 89 }