Volume configurable range 0-100

This commit is contained in:
dann-merlin
2020-02-22 12:44:13 +01:00
committed by Henrik Friedrichsen
parent 56a178dcfd
commit 45858df8a3
2 changed files with 2 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ pub struct Config {
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct SavedState {
pub volume: Option<u16>,
pub volume: Option<u8>,
pub shuffle: Option<bool>,
pub repeat: Option<String>,
}

View File

@@ -223,7 +223,7 @@ impl Spotify {
let (user_tx, user_rx) = oneshot::channel();
let volume = match &cfg.saved_state {
Some(state) => match state.volume {
Some(vol) => vol,
Some(vol) => ((std::cmp::min(vol, 100) as f32)/100.0 * (0xFFFF as f32)).ceil() as u16,
None => 0xFFFF as u16,
},
None => 0xFFFF as u16,