Minor Fix: clear album photo if no photo embeded

This commit is contained in:
tramhao 2021-04-13 14:20:00 +08:00
parent 29894636cc
commit 5b5c6be651
2 changed files with 7 additions and 4 deletions

View File

@ -270,7 +270,7 @@ func timeLRC(t uint32) string {
// GetText will fetch lyric by time in seconds
func (lyric *Lyric) GetText(time int) (string, error) {
if lyric.SyncedCaptions == nil {
if len(lyric.SyncedCaptions) == 0 {
return "", errors.New("no synced lyric found")
}

View File

@ -281,6 +281,12 @@ func (p *PlayingBar) loadLyrics(currentSongPath string) error {
p.hasTag = true
p.tag = tag
if p.albumPhoto != nil {
p.albumPhoto.Clear()
p.albumPhoto.Destroy()
p.albumPhoto = nil
}
syltFrames := tag.GetFrames(tag.CommonID("Synchronised lyrics/text"))
usltFrames := tag.GetFrames(tag.CommonID("Unsynchronised lyrics/text transcription"))
@ -324,9 +330,6 @@ func (p *PlayingBar) loadLyrics(currentSongPath string) error {
go gomu.app.QueueUpdateDraw(func() {
x, y, _, _ := p.GetInnerRect()
width, height, windowWidth, windowHeight := getConsoleSize()
if err != nil {
errorPopup(err)
}
p.albumPhoto, err = ugo.NewImage(dstImage128, (x+3)*windowWidth/width, (y+2)*windowHeight/height)
if err != nil {