From 944402114c11181fb57cdd5863c18ba051c61cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Lah?= <117428823+ziga-lah-songtradr@users.noreply.github.com> Date: Tue, 28 Nov 2023 08:57:17 +0100 Subject: [PATCH] Fix: emit time update when audio is already playing on init (#3359) * Fix timeupdate render to use requestAnimationFrame * Fixed PR issue * Reverted timeupdate event and added timer start if player is already playing * Removed ; * Added space * Ran prettier --------- Co-authored-by: Ziga Lah --- src/wavesurfer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wavesurfer.ts b/src/wavesurfer.ts index 88d54e83f..66eda1178 100644 --- a/src/wavesurfer.ts +++ b/src/wavesurfer.ts @@ -186,6 +186,11 @@ class WaveSurfer extends Player { } private initPlayerEvents() { + if (this.isPlaying()) { + this.emit('play') + this.timer.start() + } + this.mediaSubscriptions.push( this.onMediaEvent('timeupdate', () => { const currentTime = this.getCurrentTime()