diff options
Diffstat (limited to 'players.js')
-rw-r--r-- | players.js | 8 |
1 files changed, 6 insertions, 2 deletions
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() { |