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
This commit is contained in:
parent
075ce0f096
commit
848ae91b2a
28
main.go
28
main.go
|
|
@ -8682,29 +8682,15 @@ func buildVideoPane(state *appState, min fyne.Size, src *videoSource, onCover fu
|
||||||
return state.playSess != nil
|
return state.playSess != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debounced seeking - only seek after user stops dragging
|
// Immediate seeking for responsive playback
|
||||||
var seekTimer *time.Timer
|
|
||||||
var seekMutex sync.Mutex
|
|
||||||
slider.OnChanged = func(val float64) {
|
slider.OnChanged = func(val float64) {
|
||||||
if updatingProgress {
|
if updatingProgress {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateProgress(val)
|
updateProgress(val)
|
||||||
if !ensureSession() {
|
if ensureSession() {
|
||||||
return
|
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() {
|
updateVolIcon := func() {
|
||||||
if volIcon == nil {
|
if volIcon == nil {
|
||||||
|
|
@ -8963,8 +8949,8 @@ func (p *playSession) StepFrame(delta int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate target frame number
|
// Calculate current frame from time position (not from p.frameN which resets on seek)
|
||||||
currentFrame := p.frameN
|
currentFrame := int(p.current * p.fps)
|
||||||
targetFrame := currentFrame + delta
|
targetFrame := currentFrame + delta
|
||||||
|
|
||||||
// Clamp to valid range
|
// Clamp to valid range
|
||||||
|
|
@ -8986,10 +8972,8 @@ func (p *playSession) StepFrame(delta int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-pause when frame stepping
|
// Auto-pause when frame stepping
|
||||||
wasPaused := p.paused
|
|
||||||
p.paused = true
|
p.paused = true
|
||||||
p.current = offset
|
p.current = offset
|
||||||
p.frameN = targetFrame
|
|
||||||
p.stopLocked()
|
p.stopLocked()
|
||||||
p.startLocked(p.current)
|
p.startLocked(p.current)
|
||||||
p.paused = true
|
p.paused = true
|
||||||
|
|
@ -9007,8 +8991,6 @@ func (p *playSession) StepFrame(delta int) {
|
||||||
if p.frameFunc != nil {
|
if p.frameFunc != nil {
|
||||||
p.frameFunc(targetFrame)
|
p.frameFunc(targetFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = wasPaused // Keep for potential future use
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCurrentFrame returns the current frame number
|
// GetCurrentFrame returns the current frame number
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user