diff options
author | 2025-08-01 03:59:05 +0200 | |
---|---|---|
committer | 2025-08-01 03:59:05 +0200 | |
commit | 826fa7f4cf1a0f2ca28595d5f240c039a96afa56 (patch) | |
tree | dae6ddae340a085ed980b5c066dbaa0fbdf01eb4 /src | |
parent | a205c294695272ceffb2087a5375097c02ec873f (diff) | |
download | videotool-826fa7f4cf1a0f2ca28595d5f240c039a96afa56.tar.gz videotool-826fa7f4cf1a0f2ca28595d5f240c039a96afa56.tar.bz2 videotool-826fa7f4cf1a0f2ca28595d5f240c039a96afa56.tar.lz videotool-826fa7f4cf1a0f2ca28595d5f240c039a96afa56.zip |
fix: more fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Player/Player.svelte | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/lib/Player/Player.svelte b/src/lib/Player/Player.svelte index cc438f5..5ae6458 100644 --- a/src/lib/Player/Player.svelte +++ b/src/lib/Player/Player.svelte @@ -141,36 +141,37 @@ if (loadedFrameTimestamp) saveFramePosition(frame); }); let seeking = false; + let properlyFinishedMounting = false; + onMount(() => requestAnimationFrame(() => (properlyFinishedMounting = true))); $effect(() => { if (audio && video && !playing && !playbackFrameOffset) { - try { - const f = frame; - audio.currentTime = frame / video.fps; - audio.play(); - seeking = true; - (async () => { - const targetTime = (frame + 1) / video.fps; - while (audio.currentTime <= targetTime) { - await new Promise((rs) => requestAnimationFrame(rs)); - if (playing) { - seeking = false; - return; - } - if (frame !== f) return; - } - seeking = false; - audio.pause(); + if (properlyFinishedMounting) + try { + const f = frame; audio.currentTime = frame / video.fps; - })(); - } catch (error) { - console.warn(error); - } + audio.play(); + seeking = true; + (async () => { + const targetTime = (frame + 1) / video.fps; + while (audio.currentTime <= targetTime) { + await new Promise((rs) => requestAnimationFrame(rs)); + if (playing) { + seeking = false; + return; + } + if (frame !== f) return; + } + seeking = false; + audio.pause(); + audio.currentTime = frame / video.fps; + })(); + } catch (error) { + console.warn('Seek Error:', error); + } } }); const updateAudioPlayingState = (playing: boolean) => { if (audio) { - console.warn('upd'); - if (playing) audio.play(); else if (!seeking) audio.pause(); } |