Skip to content

Commit f59ede9

Browse files
committed
Correctly set group volume when fading
Fixes goldfire#539
1 parent a1305af commit f59ede9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/howler.core.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@
11291129
sound._node.gain.linearRampToValueAtTime(to, end);
11301130
}
11311131

1132-
self._startFadeInterval(sound, from, to, len, ids[i]);
1132+
self._startFadeInterval(sound, from, to, len, ids[i], typeof id === 'undefined');
11331133
}
11341134
}
11351135

@@ -1143,8 +1143,9 @@
11431143
* @param {Number} to The volume to fade to (0.0 to 1.0).
11441144
* @param {Number} len Time in milliseconds to fade.
11451145
* @param {Number} id The sound id to fade.
1146+
* @param {Boolean} isGroup If true, set the volume on the group.
11461147
*/
1147-
_startFadeInterval: function(sound, from, to, len, id) {
1148+
_startFadeInterval: function(sound, from, to, len, id, isGroup) {
11481149
var self = this;
11491150
var vol = from;
11501151
var dir = from > to ? 'out' : 'in';
@@ -1173,15 +1174,16 @@
11731174

11741175
// Change the volume.
11751176
if (self._webAudio) {
1176-
if (typeof id === 'undefined') {
1177-
self._volume = vol;
1178-
}
1179-
11801177
sound._volume = vol;
11811178
} else {
11821179
self.volume(vol, sound._id, true);
11831180
}
11841181

1182+
// Set the group's volume.
1183+
if (isGroup) {
1184+
self._volume = vol;
1185+
}
1186+
11851187
// When the fade is complete, stop it and fire event.
11861188
if ((to < from && vol <= to) || (to > from && vol >= to)) {
11871189
clearInterval(sound._interval);

0 commit comments

Comments
 (0)