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

gatt_localtime
Arsen Musayelyan 11 months ago
parent e82981e3fc
commit 7026da3f6f

@ -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" {

Loading…
Cancel
Save