Handling sound ending in update method

This commit is contained in:
Pavle Goloskokovic 2018-01-12 15:27:25 +01:00
parent 0d0df1900b
commit 72955bfe30

View file

@ -167,14 +167,18 @@ var HTML5AudioSound = new Class({
}
return;
}
// handle looping
var startTime = (this.currentMarker ? this.currentMarker.start : 0);
// handle looping and ending
var startTime = this.currentMarker ? this.currentMarker.start : 0;
var endTime = startTime + this.duration;
var currentTime = this.audio.currentTime;
if (currentTime >= endTime) {
if (this.currentConfig.loop) {
this.audio.currentTime = startTime + (currentTime - endTime);
}
else {
this.reset();
this.stopAndReleaseAudioTag();
}
}
}
},