I am working in a project, where I need to create accurate audio editor.
I noticed, that Safari has some quirky behaviour when setting currentTime on audio. It seems that, depending on the currentTime where the jump happens and where to, the actual point in time can be off 2-3 seconds even.
I made a JS fiddle to demonstrate the issue.
The relevant parts of the code are these:
jump.addEventListener('click', function () {
audio.currentTime = jumpToVal;
});
jump2.addEventListener('click', function () {
audio.currentTime = Number.parseInt(jumpToVal) + Number.parseInt(jumpBufferVal);
audio.volume = 0;
setTimeout(function () {
audio.volume = 1;
audio.currentTime = jumpToVal;
}, jumpDelayVal)
});
So basically what happens in this sample is that if trying to jump to 8s in audio after the point has been passed, the audio is started some seconds before that point. If setting the currentTime to, for example, 8 seconds less of that point and after a delay jumping to the point, it plays somewhat from the right position.
I would like to emphasise, that most likely this is just a coincidence, since the behaviour changes depending from where and to what point in time the currentTime is set. The issue is just clearest with this setting.
Compare for example to Chrome to hear the difference.
What is peculiar is that audio returns the same currentTime, no matter what is the end result. So in other terms, audio seems to "think" it is in the right position even when it is clearly not.
My questions are why is Safari so inaccurate with currentTime and if there is a workaround to this issue?
Safari version 12.0 (14606.1.36.1.9).