aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/Player
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Player')
-rw-r--r--src/lib/Player/Player.svelte10
1 files changed, 5 insertions, 5 deletions
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