Refresh frame after seek when paused
This commit is contained in:
parent
7e252fbeff
commit
61a4e4a673
33
main.go
33
main.go
|
|
@ -11335,27 +11335,50 @@ func (p *playSession) Pause() {
|
||||||
|
|
||||||
func (p *playSession) Seek(offset float64) {
|
func (p *playSession) Seek(offset float64) {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
|
||||||
if offset < 0 {
|
if offset < 0 {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use GStreamer player
|
// Use GStreamer player
|
||||||
if p.gstPlayer != nil {
|
if p.gstPlayer != nil {
|
||||||
p.gstPlayer.SeekToTime(time.Duration(offset * float64(time.Second)))
|
paused := p.paused
|
||||||
if p.paused {
|
_ = p.gstPlayer.SeekToTime(time.Duration(offset * float64(time.Second)))
|
||||||
|
if paused {
|
||||||
_ = p.gstPlayer.Pause()
|
_ = p.gstPlayer.Pause()
|
||||||
} else {
|
} else {
|
||||||
_ = p.gstPlayer.Play()
|
_ = p.gstPlayer.Play()
|
||||||
}
|
}
|
||||||
p.current = offset
|
p.current = offset
|
||||||
|
p.frameN = int(p.current * p.fps)
|
||||||
logging.Debug(logging.CatPlayer, "playSession: Seek to %.2fs", offset)
|
logging.Debug(logging.CatPlayer, "playSession: Seek to %.2fs", offset)
|
||||||
if p.prog != nil {
|
prog := p.prog
|
||||||
p.prog(p.current)
|
frameFunc := p.frameFunc
|
||||||
|
img := p.img
|
||||||
|
p.mu.Unlock()
|
||||||
|
|
||||||
|
if prog != nil {
|
||||||
|
prog(p.current)
|
||||||
|
}
|
||||||
|
if frameFunc != nil {
|
||||||
|
frameFunc(p.frameN)
|
||||||
|
}
|
||||||
|
if paused {
|
||||||
|
frame, err := p.gstPlayer.GetFrameImage()
|
||||||
|
if err == nil && frame != nil {
|
||||||
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
|
if img != nil {
|
||||||
|
img.Resource = nil
|
||||||
|
img.File = ""
|
||||||
|
img.Image = frame
|
||||||
|
img.Refresh()
|
||||||
|
}
|
||||||
|
}, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.mu.Unlock()
|
||||||
logging.Error(logging.CatPlayer, "playSession: GStreamer player not available")
|
logging.Error(logging.CatPlayer, "playSession: GStreamer player not available")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user