Fix VT_Player seeking and frame stepping

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 <noreply@anthropic.com>
This commit is contained in:
Stu Leak 2025-12-23 15:53:09 -05:00
parent e910bee641
commit 573e7894b2

28
main.go
View File

@ -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