Skip to content

Commit cf485cc

Browse files
authored
Merge pull request #1445 from themoonrat/bugfix/firefox-loop-error
Forces a buffer refresh if sound is set to loop, and is already playing
2 parents 119d31a + 59cdf90 commit cf485cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/howler.core.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,23 @@
14651465
if (loop) {
14661466
sound._node.bufferSource.loopStart = sound._start || 0;
14671467
sound._node.bufferSource.loopEnd = sound._stop;
1468+
1469+
if (self.playing(ids[i])) {
1470+
// Buffer needs to be refreshed if an active audio is playing as some browsers, like Firefox, will not loop otherwise
1471+
if (typeof sound._node.bufferSource.stop === 'undefined') {
1472+
sound._node.bufferSource.noteOff(0);
1473+
} else {
1474+
sound._node.bufferSource.stop(0);
1475+
}
1476+
1477+
self._refreshBuffer(sound);
1478+
1479+
if (typeof sound._node.bufferSource.start === 'undefined') {
1480+
sound._node.bufferSource.noteGrainOn(0, self.seek(ids[i]), 86400);
1481+
} else {
1482+
sound._node.bufferSource.start(0, self.seek(ids[i]), 86400);
1483+
}
1484+
}
14681485
}
14691486
}
14701487
}

0 commit comments

Comments
 (0)