From 573e7894b2781eae32a0d4a8afbfb678fdb1c611 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Tue, 23 Dec 2025 15:53:09 -0500 Subject: [PATCH] Fix VT_Player seeking and frame stepping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seeking Fixes: - Remove debouncing delay for immediate response - Progress bar now seeks instantly when clicked or dragged - No more 150ms lag during playback navigation Frame Stepping Fixes: - Calculate current frame from time position (current * fps) - Previously used frameN which resets to 0 on every seek - Frame stepping now accurately moves ±1 frame from actual position - Buttons now work correctly regardless of seek history Technical Details: - currentFrame = int(p.current * p.fps) instead of p.frameN - Removed seekTimer and seekMutex debouncing logic - Immediate Seek() call in slider.OnChanged for responsive UX 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- main.go | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 06ff721..848cb8e 100644 --- a/main.go +++ b/main.go @@ -8682,29 +8682,15 @@ func buildVideoPane(state *appState, min fyne.Size, src *videoSource, onCover fu return state.playSess != nil } - // Debounced seeking - only seek after user stops dragging - var seekTimer *time.Timer - var seekMutex sync.Mutex + // Immediate seeking for responsive playback slider.OnChanged = func(val float64) { if updatingProgress { return } updateProgress(val) - if !ensureSession() { - return + if ensureSession() { + state.playSess.Seek(val) } - - // Debounce seeking - wait 150ms after last change - seekMutex.Lock() - if seekTimer != nil { - seekTimer.Stop() - } - seekTimer = time.AfterFunc(150*time.Millisecond, func() { - if state.playSess != nil { - state.playSess.Seek(val) - } - }) - seekMutex.Unlock() } updateVolIcon := func() { if volIcon == nil { @@ -8963,8 +8949,8 @@ func (p *playSession) StepFrame(delta int) { return } - // Calculate target frame number - currentFrame := p.frameN + // Calculate current frame from time position (not from p.frameN which resets on seek) + currentFrame := int(p.current * p.fps) targetFrame := currentFrame + delta // Clamp to valid range @@ -8986,10 +8972,8 @@ func (p *playSession) StepFrame(delta int) { } // Auto-pause when frame stepping - wasPaused := p.paused p.paused = true p.current = offset - p.frameN = targetFrame p.stopLocked() p.startLocked(p.current) p.paused = true @@ -9007,8 +8991,6 @@ func (p *playSession) StepFrame(delta int) { if p.frameFunc != nil { p.frameFunc(targetFrame) } - - _ = wasPaused // Keep for potential future use } // GetCurrentFrame returns the current frame number