Skip to content

Commit

Permalink
Support relative volumes for groupSetVolume()
Browse files Browse the repository at this point in the history
  • Loading branch information
rhew authored and James Rhew committed Aug 24, 2014
1 parent 911370e commit 05668ee
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05668ee

Please sign in to comment.