Skip to content

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

Open
@michaelhthomas

Description

@michaelhthomas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions