From 67f4f4dad92d79dc16c40ad7223bdb93bd25b88e Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 4 Jun 2019 20:44:45 -0300 Subject: Volume slider in menubar --- players.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'players.js') 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}`) } -- cgit 1.3.0-6-gf8a5