Handling delayed playback in update method

This commit is contained in:
Pavle Goloskokovic 2018-01-11 18:31:36 +01:00
parent 3388fd018f
commit fb6b989035

View file

@ -126,7 +126,16 @@ var HTML5AudioSound = new Class({
BaseSound.prototype.stop.call(this);
},
update: function (time, delta) {
if (this.isPlaying) {
// handling delayed playback
if (this.startTime > 0) {
if (this.startTime < time) {
this.audio.currentTime += (time - this.startTime) / 1000;
this.startTime = 0;
this.audio.play();
}
}
}
},
destroy: function () {
BaseSound.prototype.destroy.call(this);