Closed irdeto-hackwestern closed 4 years ago
I've just checked and it works over here, if I'm currently in the queue.
Command tried SONOS_HOST=192.168.20.23 node examples/playSpotifyMusic.js
If I play TuneIn and clear the queue, I'm getting a different error.
Error occurred {"message":"Request failed with status code 500","name":"Error","stack":"Error: Request failed with status code 500\n at createError (/Users/stephan/Projects/node-sonos/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/Users/stephan/Projects/node-sonos/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/Users/stephan/Projects/node-sonos/node_modules/axios/lib/adapters/http.js:237:11)\n at IncomingMessage.emit (events.js:228:7)\n at endReadableNT (_stream_readable.js:1185:12)\n at processTicksAndRejections (internal/process/task_queues.js:81:21)","config":{"url":"http://192.168.20.23:1400/MediaRenderer/AVTransport/Control","method":"post","data":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Seek xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Unit>TRACK_NR</Unit><Target>1</Target></u:Seek></s:Body></s:Envelope>","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"text/xml; charset=utf8","SOAPAction":"\"urn:schemas-upnp-org:service:AVTransport:1#Seek\"","User-Agent":"axios/0.19.0","Content-Length":289},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1}}
I've solved it by changing these lines to:
.then(async result => {
await this.selectQueue()
return this.selectTrack(result.FirstTrackNumberEnqueued)
})
Can you @irdeto-hackwestern check if that solves the issue? @bencevans do you see any problems with this solution?
Apart from this issue
Node Version 9.6.1 is almost 2 years old, and wasn't a LTS version. node-sonos is tested against version 8, 10 and the latest LTS. So my first suggestion is to update your node version.
Just a quick update. Same thing is happening to me. It's adding the track to the queue but then not playing it. Using node 12.16.1 LTS.
Code suggestion above fixed the issue.
EDIT: Just noticed that spotify playlist URIs also cause error 500. even with the above fix.
:tada: This issue has been resolved in version 1.13.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
When attempting to run the example playSpotifyMusic.js script, a 500 error is returned.
ERROR:
Error occurred {"message":"Request failed with status code 500","name":"Error","stack":"Error: Request failed with status code 500\n at createError (/Users/user/dev/node/sonosPlayer/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/Users/user/dev/node/sonosPlayer/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/Users/user/dev/node/sonosPlayer/node_modules/axios/lib/adapters/http.js:236:11)\n at IncomingMessage.emit (events.js:132:15)\n at endReadableNT (_stream_readable.js:1101:12)\n at process._tickCallback (internal/process/next_tick.js:152:19)","config":{"url":"http://192.168.1.21:1400/MediaRenderer/AVTransport/Control","method":"post","data":"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><u:AddURIToQueue xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\">0 x-sonos-spotify:spotify%3atrack%3a6sYJuVcEu4gFHmeTLdHzRz <DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="00032020spotify%3atrack%3a6sYJuVcEu4gFHmeTLdHzRz" restricted="true"><dc:title></dc:title><upnp:class>object.item.audioItem.musicTrack</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON2311X#Svc2311-0-Token</desc></item></DIDL-Lite> 0 1 </u:AddURIToQueue></s:Body></s:Envelope>","headers":{"Accept":"application/json, text/plain, /","Content-Type":"text/xml; charset=utf8","SOAPAction":"\"urn:schemas-upnp-org:service:AVTransport:1#AddURIToQueue\"","User-Agent":"axios/0.19.1","Content-Length":1138},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1}}
Code
const Sonos = require('sonos').Sonos const Regions = require('sonos').SpotifyRegion const sonos = new Sonos(process.env.SONOS_HOST || '192.168.1.21') sonos.setSpotifyRegion(Regions.EU)
var spotifyUri = 'spotify:track:6sYJuVcEu4gFHmeTLdHzRz'
sonos.play(spotifyUri) .then(success => { console.log('Yeay') return sonos.currentTrack() }) .then(track => { console.log(JSON.stringify(track, null, 2)) }) .catch(err => { console.log('Error occurred %j', err) })
Versions (and Environment)
Node version: v9.6.1 node-sonos version: latest OS: mac mojave 10.14.6