我正在动态创建音频文件并更改动态来源。但是,当我更改src并尝试更改currentTime时,我总是得到一个无效状态错误。你如何去测试它?或者更好地在事件准备好之后触发事件,然后调用currentTime来更改其音频位置。HTML5音频 - 测试无效状态错误(或Dom异常11)
this.doneLoading = function(aTime){
try{
this.mAudioPlayer.currentTime = aTime/1000.0;
}catch(err){
console.log(err);
}
this.mAudioPlayer.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('canplaythrough', this.doneLoading(aTime), 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();
}
};
2012-10-10
Neablis