bencevans / node-sonos

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

Spotify session blocks play #456

Closed phoenixrising87 closed 4 years ago

phoenixrising87 commented 4 years ago

Expected Behavior

Spotify session should not block from playing different uri.

Current Behavior

If playing a song on sonos due to selecting from the spotify app the sonos device as player, it is not possible anymore to play another uri. It does not matter if this is another spotify uri or from the library itself. It will end in a 701 error. In the sonos app (on my iOS device) I can select the player and cancel the spotify session. Only after doing this it’s possible to play another uri again.

Possible Solution

Does anybody know how to cancel this session? On the OS X application of Sonos this option is not existing. I also tried with Rwireshark to observe the request, but it seems this is not done with the soap api.

svrooij commented 4 years ago

Just select another source.

const Sonos = require('../').Sonos
const sonos = new Sonos(process.env.SONOS_HOST || '192.168.2.11')

sonos.selectQueue()
  .then(success => {
    console.log('Yeay')
  })

// Or actually anything that calls 
sonos.setAVTransportURI('uri');

// Like 
sonos.playSpotifyRadio(...)
sonos.playTuneinRadio(...)

If Spotify starts a session, it doesn't use the queue, it manages it's own queue. So by telling sonos to start another source your problem is solved.