尝试每次测量延迟:
function playSeamless(clip,next) {
if(!next) {
next = clip.cloneNode(true);
next.controls = false;
}
var start = Date.now();
clip.play();
setTimeout(function() {
var time = (Date.now() - start) / 1000;
var position = clip.currentTime;
var delay = time - position;
setTimeout(function() {
// Set desired currentTime on next here and adjust delay above
playSeamless(next,clip);
},(clip.duration - clip.currentTime - delay * 2.35) * 1000 | 0);
},200);
}
playSeamless(yourAudioClip);
这是更好的,但不是完全准确的,所以我需要调整* 2.35或减去或减少某事.