Handle case where artists value is a single string rather than a slice. Fixes Arsen6331/itd#9.

This commit is contained in:
Elara 2022-03-04 12:04:37 -08:00
parent b6ba971d50
commit 36aee2e1fe

View File

@ -163,12 +163,17 @@ func OnChange(cb func(ChangeType, string)) {
} }
cb(ChangeTypeAlbum, album) cb(ChangeTypeAlbum, album)
} else if strings.HasSuffix(name, "artist") { } else if strings.HasSuffix(name, "artist") {
artists := val.Value().([]string) var artists string
artistStr := strings.Join(artists, ", ") switch artistVal := val.Value().(type) {
if artistStr == "" { case string:
artistStr = "Unknown " + ChangeTypeArtist.String() artists = artistVal
case []string:
artists = strings.Join(artistVal, ", ")
} }
cb(ChangeTypeArtist, artistStr) if artists == "" {
artists = "Unknown " + ChangeTypeArtist.String()
}
cb(ChangeTypeArtist, artists)
} }
} }
} else if name == "PlaybackStatus" { } else if name == "PlaybackStatus" {