Intento vincular un valor actualizado cada segundo (como un contador), pero tengo un problema realmente extraño. Cuando inicio el temporizador, el valor no es vinculante, pero cuando lo detengo, puedo ver el valor total (si hago una pausa después de 9 segundos, el valor es 9, por ejemplo).
Más extraño, cuando reinicio el temporizador, el valor se vincula correctamente.
Pero el problema es que necesito vincular este valor al principio...
Este es mi componente real:
ngOnInit() { this.subscription = this.FunctionsService.getContent().subscribe( res => { this.audioUrl = res.url; this.getDuration(this.audioUrl); if(this.audioUrl){ this.start(this.audioUrl); } } ) } start(audioUrl){ this.audio = new Pizzicato.Sound(audioUrl, () => { this.play(); }); setTimeout(()=>{ this.isPlaying = true; this.ready = true; },1000) } play(){ this.sound.play(); this.startTimer(); this.isPlaying = true; } pause(){ this.isPlaying = false; this.pauseTimer(); this.sound.pause(); } getDuration(src:any) { var audio = new Audio(src); let self = this; audio.onloadedmetadata = function() { console.log(audio.duration); }; } startTimer(){ var self = this; this.timer = setInterval(()=>{ self.currentTime++ console.log(self.currentTime); },1000) } pauseTimer(){ var self = this; clearInterval(self.timer); }Me he perdido algo ? Gracias a todos por su ayuda !