Sto creando dinamicamente un file audio e cambiando la sorgente al volo. Tuttavia, dopo aver cambiato il src e provare a cambiare il tempo corrente, ottengo sempre un errore di stato non valido. Come si fa a testare per questo? O meglio attivare un evento quando è pronto e quindi chiamare currentTime per cambiare la sua posizione audio.audio HTML5 - test per errore di stato non valido (o Dom eccezione 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();
}
};
QUESTO FUNZIONA Penso che questa dovrebbe essere la risposta accettata THX – Prozi