我试图在从服务器传输音频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();
}
};
这不是一个缓冲问题,因为无论等待多久它都不会在设定时间成功。
答案 0 :(得分:1)
尝试交换以下两行的位置:
this.mAudioPlayer.play();
this.mAudioPlayer.currentTime = aTime / 1000.0;