Dynamicznie tworzę plik audio i zmieniam źródło w locie. Jednak po zmianie src i próbie zmiany currentTime zawsze pojawia się błąd Invalid state. Jak radzisz sobie z testowaniem? Lub lepiej zwolnij zdarzenie, gdy jest gotowe, a następnie wywołaj currentTime, aby zmienić swoją pozycję audio.Dźwięk HTML5 - test na błąd nieprawidłowego stanu (Lub 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();
}
};
TO DZIAŁA Myślę, że powinna to być zaakceptowana odpowiedź THX – Prozi