Skip to content

Commit

Permalink
Merge pull request #21 from rhew/relative-group-volume
Browse files Browse the repository at this point in the history
Support relative volumes for groupSetVolume()
  • Loading branch information
jishi committed Nov 26, 2014
2 parents cde657b + 05668ee commit bd435a1
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 @@ -516,9 +516,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 bd435a1

Please sign in to comment.