Skip to content

Commit

Permalink
Correctly set group volume when fading
Browse files Browse the repository at this point in the history
Fixes #539
  • Loading branch information
goldfire committed Nov 2, 2017
1 parent a1305af commit f59ede9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@
sound._node.gain.linearRampToValueAtTime(to, end);
}

self._startFadeInterval(sound, from, to, len, ids[i]);
self._startFadeInterval(sound, from, to, len, ids[i], typeof id === 'undefined');
}
}

Expand All @@ -1143,8 +1143,9 @@
* @param {Number} to The volume to fade to (0.0 to 1.0).
* @param {Number} len Time in milliseconds to fade.
* @param {Number} id The sound id to fade.
* @param {Boolean} isGroup If true, set the volume on the group.
*/
_startFadeInterval: function(sound, from, to, len, id) {
_startFadeInterval: function(sound, from, to, len, id, isGroup) {
var self = this;
var vol = from;
var dir = from > to ? 'out' : 'in';
Expand Down Expand Up @@ -1173,15 +1174,16 @@

// Change the volume.
if (self._webAudio) {
if (typeof id === 'undefined') {
self._volume = vol;
}

sound._volume = vol;
} else {
self.volume(vol, sound._id, true);
}

// Set the group's volume.
if (isGroup) {
self._volume = vol;
}

// When the fade is complete, stop it and fire event.
if ((to < from && vol <= to) || (to > from && vol >= to)) {
clearInterval(sound._interval);
Expand Down

0 comments on commit f59ede9

Please sign in to comment.