bencevans / node-sonos

🔈 Sonos Media Player Interface/Client

Home Page:https://www.npmjs.com/package/sonos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

michaelhthomas opened this issue · comments

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