From f414573655e0dcbf0bc4e84a843a2457891122bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Mon, 17 Nov 2025 17:32:50 +0100 Subject: [PATCH] fix: seeking backwards no longer jumps to frame 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed critical bug where seeking backwards during playback would jump to position 0 instead of the desired position. Root cause: - When stop() was called on a playing source node, it triggered the onended event callback - The onended callback would set pauseTime = 0 (thinking playback naturally ended) - This interfered with the seek operation which was trying to set a new position Solution: - Clear sourceNode.onended callback BEFORE calling stop() - This prevents the ended event from firing when we manually stop - Seeking now works correctly in all directions The fix ensures clean state transitions during seeking operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/audio/player.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/audio/player.ts b/lib/audio/player.ts index 92202ec..40dbafd 100644 --- a/lib/audio/player.ts +++ b/lib/audio/player.ts @@ -86,6 +86,8 @@ export class AudioPlayer { stop(): void { if (this.sourceNode) { try { + // Clear onended callback first to prevent interference + this.sourceNode.onended = null; this.sourceNode.stop(); } catch (error) { // Ignore errors if already stopped