From 79ddf613f9173e700e2ef1b1adb974478df36d98 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 2 Mar 2026 13:39:15 +0530 Subject: [PATCH] fix(27): do full reset sequence when playing from beginning Native client needs Stop -> Seek(0) -> Play sequence to reliably start playback after track has finished. Previously we only did this when "atEnd", but after track finishes and resets to 0, the "atEnd" check is false. Fix: Also do the full reset sequence when position is at the beginning (< 100ms). This ensures native client is in the right state whether starting fresh or restarting after track finished. Co-Authored-By: Claude Opus 4.5 --- .../client/JKSessionBackingTrackPlayer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jam-ui/src/components/client/JKSessionBackingTrackPlayer.js b/jam-ui/src/components/client/JKSessionBackingTrackPlayer.js index dfcc10b9e..02f11c994 100644 --- a/jam-ui/src/components/client/JKSessionBackingTrackPlayer.js +++ b/jam-ui/src/components/client/JKSessionBackingTrackPlayer.js @@ -299,15 +299,16 @@ const JKSessionBackingTrackPlayer = ({ // Check if we're at the very end (within 50ms to avoid false positives from slider dragging) const atEnd = currentPositionMs >= durationMs - 50 && durationMs > 0; - console.log('[PLAY] At end check:', { currentPositionMs, durationMs, atEnd, threshold: durationMs - 50 }); + // Check if we're at the beginning (position 0 or very close) + const atBeginning = currentPositionMs < 100; + console.log('[PLAY] Position check:', { currentPositionMs, durationMs, atEnd, atBeginning }); - if (atEnd) { - console.log('[PLAY] At end, resetting to start'); - // Stop first to reset state + if (atEnd || atBeginning) { + // Native client needs Stop -> Seek -> Play sequence to reliably start + // This handles both "at end" and "at beginning after track finished" cases + console.log('[PLAY] At end or beginning, doing full reset sequence'); await jamClient.SessionStopPlay(); - // Seek to start await jamClient.SessionTrackSeekMs(0); - // Update UI state setCurrentPositionMs(0); setCurrentTime('0:00'); }