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 e82981e3fc
commit 7026da3f6f

View File

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