I have to play specific short piece from source audio using "currentTime" for setting start time and "timeupdate" event to stop audio at special moment.
And I noticed, that on few early timeupdate events currentTime can become less than it's initial value, despite there is no "rewind" actions. Here is code example:
var start = 1;
var end = 1.3;
var audio = document.getElementById('audio');
audio.addEventListener('timeupdate', function () {
console.log(audio.currentTime);
if (audio.currentTime < start || audio.currentTime > end) {
audio.pause();
}
});
audio.currentTime = start;
audio.play();
For example, output of console log can be this:
1
0.85
0.85
1
1.02
...
More demonstrative example: https://jsfiddle.net/threisdd/tz0cys2a/1/
Tested on iPad with iOS 11.4.1. This problem appears only on very short time ranges ~0.3sec.
from HTML5 audio on IOS: currentTime less than initial value
No comments:
Post a Comment