node-sonos-http-api
node-sonos-http-api copied to clipboard
500 when trying to play from spotify
I've been trying to troubleshoot playback issues recently with my Sonos and this program. I use it as part of https://github.com/ryanolf/node-sonos-nfc to read nfc tags and play music. I think it has been having issues for a while but spent the weekend troubleshooting, but appreciate wider support to help. It used to work fine - but I acknowledge that Sonos update screw ups have caused no end of issues - so I'm trying to figure out if there is something that can be fixes to make work again.
To isolate the issues I've been running just the node-sonos-http-api program locally using npm start.
Problem
❌ I seem to be unable to lookup or play music from Spotify.
Example: Trying to play One by One by Foo Fighters. The spotify link is https://open.spotify.com/album/1zQ6F8gMagKcPL4SoA80cx?si=zfp9lWkxQfKrgLO_X6Qo6Q. Following the rough advice from here I have crafted the album URI as:
spotify:album:1zQ6F8gMagKcPL4SoA80cx
I've then constructed into a URL to play locally on a Roam 2: http://localhost:5005/Roam%202/spotify/now/spotify:album:1zQ6F8gMagKcPL4SoA80cx
However I get the following error returned:
{
"status": "error",
"error": "Got status 500 when invoking /MediaRenderer/AVTransport/Control",
"stack": "Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control\n at Object.invoke (/home/john/Development/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:99:10)\n at Player.addURIToQueue (/home/john/Development/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:616:15)\n at /home/john/Development/node-sonos-http-api/lib/actions/spotify.js:33:36\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
}
What does work?
I have confirmed that:
- ✅ Playing music from my local library (through favourites) works flawlessly.
http://localhost:5005/Roam%202/favourite/Phil%20Collins - ✅ Pausing the player works no issue
http://localhost:5005/Roam%202/pause - ✅ Resuming playback works no issue
http://localhost:5005/Roam%202/play
Spotify Credentials setup
I have created a settings.json file in the root project with spotify details. It seems the spotify developer portal has changed a little so the info in readme a little ambiguous. I set up with the following details:
I assume the redirect isn't needed. I didn't know the required scope so I assumed Web API.
The settings.json file simply looks like:
{
"spotify": {
"clientId": "<redacted-for-github>",
"clientSecret": "<redacted-for-github>"
}
}
Any suggestions to help greatly appreciated.