Tôi đang tạo động một tệp âm thanh và thay đổi nguồn khi đang di chuyển. Tuy nhiên sau khi tôi thay đổi src và cố gắng thay đổi currentTime tôi luôn luôn nhận được một lỗi trạng thái không hợp lệ. Làm thế nào để bạn đi về thử nghiệm cho nó? Hoặc tốt hơn là cháy một sự kiện khi nó sẵn sàng và sau đó gọi currentTime để thay đổi vị trí âm thanh của nó.Kiểm tra âm thanh HTML5 cho Lỗi trạng thái không hợp lệ (Hoặc Dom Exception 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();
}
};
CÔNG TRÌNH NÀY Tôi nghĩ rằng đây sẽ là câu trả lời được chấp nhận THX – Prozi