我试图在从服务器流式传输音频 src 时设置 currentTime。在所有其他浏览器上,这都可以正常工作,但是在 IE9 上,当我设置 currentTime 并调用 play 时,它会跳回到开头。
this.playAtTime = function(aTime) {
Debug("play at time audio: " + aTime);
Debug("this.mAudioPlayer.currentTime: " + this.mAudioPlayer.currentTime);
this.startTime = aTime;
if (this.mAudioPlayer.src != this.mAudioSrc) {
this.mAudioPlayer = new Audio();
this.mAudioPlayer.src = this.mAudioSrc;
this.mAudioPlayer.load();
this.mAudioPlayer.play();
this.mAudioPlayer.addEventListener('loadedmetadata', function(){ this.currentTime = aTime / 1000.0; }, false );
}
else if ((isChrome() || isMobileSafari()) && aTime == 0) {
this.mAudioPlayer.load();
this.mAudioPlayer.currentTime = aTime / 1000.0;
this.mAudioPlayer.play();
Debug("Reloading audio");
}else{
this.mAudioPlayer.currentTime = aTime / 1000.0;
this.mAudioPlayer.play();
}
};
这不是缓冲问题,因为无论等待多长时间,它都不会在设置时间成功。