From 5762a825d589704a53aaabb425d9470c726bbc0d Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 24 Jan 2019 23:32:42 -0400 Subject: (v), (V) - Volume controls "v" increases because it's lowercase and therefore more likely to be accidentally pressed, hence more likely to confuse the user when it decreases the volume (if it decreased the volume - since it increases the volume, it generally doesn't seem to have any effect until you've already discovered that v and V are used for volume controls). --- players.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'players.js') diff --git a/players.js b/players.js index fdcd038..e9cf76e 100644 --- a/players.js +++ b/players.js @@ -50,6 +50,7 @@ class Player extends EventEmitter { this.disablePlaybackStatus = false this.isLooping = false + this.volume = 100 } set process(newProcess) { @@ -98,6 +99,7 @@ module.exports.MPVPlayer = class extends Player { if (this.isLooping) { opts.unshift('--loop') } + opts.unshift('--volume', this.volume) return opts } @@ -174,11 +176,13 @@ module.exports.ControllableMPVPlayer = class extends module.exports.MPVPlayer { } volUp(amount) { - this.sendCommand(`add volume +${parseFloat(amount)}`) + this.volume = Math.min(100, this.volume + amount) + this.sendCommand(`set volume ${this.volume}`) } volDown(amount) { - this.sendCommand(`add volume -${parseFloat(amount)}`) + this.volume = Math.max(0, this.volume - amount) + this.sendCommand(`set volume ${this.volume}`) } togglePause() { -- cgit 1.3.0-6-gf8a5