diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-04-25 15:51:31 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-04-25 15:51:31 +0530 |
| commit | a8161521d099c8add12b54db519c74f976e2a55c (patch) | |
| tree | eb33571279ce37a7ef610ded639145fa732f7cb2 /src/connection.rs | |
| parent | 00c5c12d82a2d6b9ca5f56f6ca468b2b3212c792 (diff) | |
add keymaps to readme.md and minor changes
Diffstat (limited to 'src/connection.rs')
| -rwxr-xr-x | src/connection.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/connection.rs b/src/connection.rs index a741206..b77da1b 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -14,6 +14,7 @@ pub struct Connection { pub state: String, pub elapsed: Duration, pub total_duration: Duration, + pub volume: u8, } impl Connection { @@ -26,8 +27,8 @@ impl Connection { .into_iter() .map(|x| x.file) .collect(); - let (elapsed, total) = conn.status().unwrap().time.unwrap_or_default(); + let volume: u8 = conn.status().unwrap_or_default().volume as u8; Ok(Self { conn, @@ -35,6 +36,7 @@ impl Connection { state: "Stopped".to_string(), elapsed, total_duration: total, + volume, }) } @@ -77,6 +79,10 @@ impl Connection { self.total_duration = total; } + pub fn update_volume(&mut self) { + self.volume = self.conn.status().unwrap_or_default().volume as u8; + } + pub fn get_progress_ratio(&self) -> f64 { let total = self.total_duration.as_secs_f64(); if total == 0.0 { @@ -84,7 +90,7 @@ impl Connection { } else { let ratio = self.elapsed.as_secs_f64() / self.total_duration.as_secs_f64(); if ratio > 1.0 || ratio == 0.0 { - 1.0 + 0.0 } else { ratio } |
