From dd55f45ea8a568c6a4bed4338eef41d342e58475 Mon Sep 17 00:00:00 2001
From: memdmp <memdmp@estrogen.zone>
Date: Fri, 1 Aug 2025 01:07:15 +0200
Subject: fix: another bug

---
 src/lib/Player/Player.svelte | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/lib/Player/Player.svelte')

diff --git a/src/lib/Player/Player.svelte b/src/lib/Player/Player.svelte
index a742857..078e84a 100644
--- a/src/lib/Player/Player.svelte
+++ b/src/lib/Player/Player.svelte
@@ -77,12 +77,11 @@
 				const timeDelta = Math.abs(desiredTime - audio.currentTime);
 				// If we get too out of lock-step with audio, we re-sync - we assume audio source is accurate*, as to avoid too much jumping
 				// *it may not be
-				if (desiredTime < audio.duration && timeDelta > 0.1) {
+				if (desiredTime < audio.duration - 0.5 && timeDelta > 0.1) {
 					if (timeDelta > 0.3) {
 						// too out of sync, we trust ourselves more
 						audio.currentTime = desiredTime;
 					} else {
-						// just change the rendered frame and hope its good enough
 						f = audio.currentTime * video.fps;
 					}
 				}
@@ -94,7 +93,7 @@
 				playing = false;
 			}
 			frame = f;
-			renderPreviewFrame(video, frame).then(() =>
+			renderPreviewFrame(video, f).then(() =>
 				requestAnimationFrame(() => (playing ? startPlaybackLoop(id) : void 0))
 			);
 		}
@@ -157,12 +156,13 @@
 			}
 		}
 	});
-	$effect(() => {
+	const updateAudioPlayingState = (playing: boolean) => {
 		if (audio) {
 			if (playing) audio.play();
 			else audio.pause();
 		}
-	});
+	};
+	$effect(() => updateAudioPlayingState(playing));
 </script>
 
 <svelte:window
-- 
cgit v1.2.3

