我正在尝试从服务器流式传输音频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();
}
};
这不是缓冲的问题,因为无论等待多长时间,它在设置时都不会成功。
最佳答案
尝试交换以下两行的位置:
this.mAudioPlayer.play();
this.mAudioPlayer.currentTime = aTime / 1000.0;
关于javascript - 在IE9中设置currentTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940852/