diff options
author | Florrie <towerofnix@gmail.com> | 2019-06-04 20:44:45 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-06-04 20:44:45 -0300 |
commit | 67f4f4dad92d79dc16c40ad7223bdb93bd25b88e (patch) | |
tree | 34bd9d687bc75f7b5497442428524b3fbe0ee733 /players.js | |
parent | 872dacbdbfa44f14b26f1edd1d36b06e0cfd14fe (diff) |
Volume slider in menubar
Diffstat (limited to 'players.js')
-rw-r--r-- | players.js | 11 |
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}`) } |