bencevans / node-sonos

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

Error playing sonos tracks #486

Closed reconbot closed 3 years ago

reconbot commented 3 years ago

When using the play method passing a track id is giving me an error.

Expected Behavior

It should play "Baby you can drive my car" by the Beatles

Current Behavior

A promise rejection with this error.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <s:Body>
    <s:Fault>
      <faultcode>s:Client</faultcode>
      <faultstring>UPnPError</faultstring>
      <detail>
        <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
          <errorCode>800</errorCode>
        </UPnPError>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

Sample code or executed example

The example sonos code shows this error. However here is mine.

const { AsyncDeviceDiscovery } = require('sonos')
const car = 'spotify:track:06ypiqmILMdVeaiErMFA91'
const discovery = new AsyncDeviceDiscovery()
discovery.discover().then(async sonos => {
  console.log(await sonos.play(car))
}).catch(err => {
  console.error("error", err)
  process.exit(0)
})

Versions (and Environment)

Node version: v14.8.0 node-sonos version: 1.14.0 OS: OSX 10.15.7

svrooij commented 3 years ago

Did you set the spotify region? Could you test this sample, to isolate this specific request.

svrooij commented 3 years ago

I've tried this locally, and at my PC it just works. Do you have VSCode?

Can you checkout the repository, add a .vscode/launch.json file with the following content:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch current example",
      "program": "${file}",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "env": {
        "DEBUG":"sonos:*",
        "SONOS_HOST":"192.168.x.x" // Replace this with your SONOS IP
      },
    }
  ]
}

Then navigate to examples/playSpotifyMusic.js, replace the spotify url to your own, and press F5. This will launch the debugger. You can even set breakpoints to see exactly what is going on.

Since this is working on my computer, I'm closing this issue. You can always re-open this issue is you've tried the above and it still doesn't work.