« get me outta code hell

Volume slider in menubar - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/players.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-06-04 20:44:45 -0300
committerFlorrie <towerofnix@gmail.com>2019-06-04 20:44:45 -0300
commit67f4f4dad92d79dc16c40ad7223bdb93bd25b88e (patch)
tree34bd9d687bc75f7b5497442428524b3fbe0ee733 /players.js
parent872dacbdbfa44f14b26f1edd1d36b06e0cfd14fe (diff)
Volume slider in menubar
Diffstat (limited to 'players.js')
-rw-r--r--players.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/players.js b/players.js
index 2f7a574..0c296b3 100644
--- a/players.js
+++ b/players.js
@@ -141,12 +141,17 @@ module.exports.ControllableMPVPlayer = class extends module.exports.MPVPlayer {
   }
 
   volUp(amount) {
-    this.volume = Math.min(100, this.volume + amount)
-    this.sendCommand(`set volume ${this.volume}`)
+    this.setVolume(this.volume + amount)
   }
 
   volDown(amount) {
-    this.volume = Math.max(0, this.volume - amount)
+    this.setVolume(this.volume - amount)
+  }
+
+  setVolume(value) {
+    this.volume = value
+    this.volume = Math.max(0, this.volume)
+    this.volume = Math.min(100, this.volume)
     this.sendCommand(`set volume ${this.volume}`)
   }