bencevans / node-sonos

🔈 Sonos Media Player Interface/Client
https://www.npmjs.com/package/sonos
MIT License
703 stars 147 forks source link

Sonos.getTrack: track.albumArtURI.startsWith is not a function. #516

Open michaelhthomas opened 3 years ago

michaelhthomas commented 3 years ago

Expected Behavior

Calling Sonos.getTrack() should return null for the album art if no album art is returned from Sonos, rather than causing an error.

Current Behavior

When calling Sonos.getTrack(), the following error is shown

UnhandledPromiseRejectionWarning: TypeError: track.albumArtURI.startsWith is not a function.

Possible Solution

The issue is most likely that track.albumArtURI is returning null or some non-string value, causing an exception, but I have not confirmed that to be the case. This issue only occurs about every other time I run the example code below, so it may be that the Sonos is not returning the proper response in time?

Sample code or executed example

const { DeviceDiscovery } = require('sonos')

// find one device
DeviceDiscovery().once('DeviceAvailable', (device) => {
  console.log('found device at ' + device.host)
  device.currentTrack().then((response) => console.log(response))
})

Versions (and Environment)

Node version: 14.17.4 node-sonos version: 1.14.1 OS: Linux