Increase/Decrease volume by 5 (#298)

* Increase/Decrease volume by 5

* Fixed static value

* use fallback value in case parsing fails

fixes #282

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
Saul Chavez Sanchez
2020-10-22 13:21:49 -05:00
committed by GitHub
parent da915ab563
commit c9d02507ac
4 changed files with 29 additions and 13 deletions

View File

@@ -148,13 +148,19 @@ impl CommandManager {
}
Ok(None)
}
Command::VolumeUp => {
let volume = self.spotify.volume().saturating_add(VOLUME_PERCENT);
Command::VolumeUp(amount) => {
let volume = self
.spotify
.volume()
.saturating_add(VOLUME_PERCENT * amount);
self.spotify.set_volume(volume);
Ok(None)
}
Command::VolumeDown => {
let volume = self.spotify.volume().saturating_sub(VOLUME_PERCENT);
Command::VolumeDown(amount) => {
let volume = self
.spotify
.volume()
.saturating_sub(VOLUME_PERCENT * amount);
debug!("vol {}", volume);
self.spotify.set_volume(volume);
Ok(None)
@@ -294,8 +300,11 @@ impl CommandManager {
"Shift+b".into(),
Command::Seek(SeekDirection::Relative(-10000)),
);
kb.insert("+".into(), Command::VolumeUp);
kb.insert("-".into(), Command::VolumeDown);
kb.insert("+".into(), Command::VolumeUp(1));
kb.insert("]".into(), Command::VolumeUp(5));
kb.insert("-".into(), Command::VolumeDown(1));
kb.insert("[".into(), Command::VolumeDown(5));
kb.insert("r".into(), Command::Repeat(None));
kb.insert("z".into(), Command::Shuffle(None));
kb.insert("x".into(), Command::Share(TargetMode::Current));