From 5817598c485c93184e8bff2d26d113ff7de721b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Tue, 18 Nov 2025 07:16:07 +0100 Subject: [PATCH] fix: playback position animation frame not updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed issue where currentTime wasn't updating during playback: - Removed 'isPlaying' from updatePlaybackPosition dependencies - This was causing the RAF loop to stop when state changed - Now animation frame continues running throughout playback - Playhead now updates smoothly in waveform and timeline slider 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/hooks/useMultiTrackPlayer.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/hooks/useMultiTrackPlayer.ts b/lib/hooks/useMultiTrackPlayer.ts index 48aa70b..90a707c 100644 --- a/lib/hooks/useMultiTrackPlayer.ts +++ b/lib/hooks/useMultiTrackPlayer.ts @@ -34,7 +34,7 @@ export function useMultiTrackPlayer(tracks: Track[]) { }, [tracks]); const updatePlaybackPosition = useCallback(() => { - if (!audioContextRef.current || !isPlaying) return; + if (!audioContextRef.current) return; const elapsed = audioContextRef.current.currentTime - startTimeRef.current; const newTime = pausedAtRef.current + elapsed; @@ -43,12 +43,16 @@ export function useMultiTrackPlayer(tracks: Track[]) { setIsPlaying(false); setCurrentTime(0); pausedAtRef.current = 0; + if (animationFrameRef.current) { + cancelAnimationFrame(animationFrameRef.current); + animationFrameRef.current = null; + } return; } setCurrentTime(newTime); animationFrameRef.current = requestAnimationFrame(updatePlaybackPosition); - }, [isPlaying, duration]); + }, [duration]); const play = useCallback(() => { if (tracks.length === 0 || tracks.every(t => !t.audioBuffer)) return;