Creating loop buffer source if looping is set in config

This commit is contained in:
Pavle Goloskokovic 2017-12-21 16:58:43 +01:00
parent 636275bc85
commit e612e2eaae

View file

@ -160,6 +160,23 @@ var WebAudioSound = new Class({
}
// else was stopped
};
if(this.currentConfig.loop) {
this.loopSource = this.manager.context.createBufferSource();
this.loopSource.buffer = this.audioBuffer;
this.loopSource.connect(this.muteNode);
this.loopSource.onended = function (ev) {
if (ev.target === _this.source) {
// sound ended
if (_this.currentConfig.loop) {
_this.hasLooped = true;
}
else {
_this.hasEnded = true;
}
}
// else was stopped
};
}
this.applyConfig();
this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration));
this.resetConfig();