From 05668eea967cc1a8636d71889f4ab1c680635205 Mon Sep 17 00:00:00 2001 From: James Rhew Date: Sat, 23 Aug 2014 20:43:35 -0400 Subject: [PATCH] Support relative volumes for groupSetVolume() --- lib/player.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/player.js b/lib/player.js index 6cdc5375..417b77f1 100644 --- a/lib/player.js +++ b/lib/player.js @@ -498,9 +498,18 @@ Player.prototype.groupSetVolume = function (volumeLevel, callback) { var actions = []; var count = 0; var groupVolume = this.groupState.volume; - var deltaVolume = volumeLevel - groupVolume; - var newVolume; + var deltaVolume; + // If prefixed with + or - + if (/^[+-]/.test(volumeLevel)) { + deltaVolume = parseInt(volumeLevel); + volumeLevel = groupVolume + parseInt(volumeLevel); + } else { + volumeLevel = parseInt(volumeLevel); + deltaVolume = volumeLevel - groupVolume; + } + + var newVolume; for (var uuid in this.discovery.players) { var player = this.discovery.players[uuid]; if (player.coordinator.uuid != this.uuid) continue;