From d8ebc17566ed79fd4e8684fc8dc0b7200f4c5cfe Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 18 May 2024 16:26:36 -0700 Subject: [PATCH] make sure to jump straight to correct lyric for the first time update --- ui/widgets/lyricsviewer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/widgets/lyricsviewer.go b/ui/widgets/lyricsviewer.go index 9354aaf..ca410c3 100644 --- a/ui/widgets/lyricsviewer.go +++ b/ui/widgets/lyricsviewer.go @@ -17,6 +17,10 @@ type LyricsViewer struct { nextLyricLine int lastPlayPos float64 + // keeps track if UpdatePlayPos has been called yet + // for the current lyrics + firstUpdate bool + container *fyne.Container isEmpty bool } @@ -33,6 +37,7 @@ func NewLyricsViewer() *LyricsViewer { func (l *LyricsViewer) SetLyrics(lyrics *mediaprovider.Lyrics) { l.lyrics = lyrics l.nextLyricLine = 0 + l.firstUpdate = true if lyrics == nil || len(lyrics.Lines) == 0 { if !l.isEmpty { l.container.Objects[0] = &l.noLyricsLabel @@ -62,8 +67,9 @@ func (l *LyricsViewer) UpdatePlayPos(timeSecs float64) { if l.lyrics == nil || !l.lyrics.Synced { return } - if timeSecs < l.lastPlayPos { + if l.firstUpdate || timeSecs < l.lastPlayPos { l.OnSeeked(timeSecs) + l.firstUpdate = false return } l.lastPlayPos = timeSecs