pckhib / node-red-contrib-spotify

Node-RED node for Spotify Web API
MIT License
13 stars 16 forks source link

Spotify doesn't always respond #23

Open brendonhatcher opened 3 years ago

brendonhatcher commented 3 years ago

I have a play node which works most of the time. However, under the following circumstances, it does not.

  1. Open Spotify on my Android phone, but do not press play on the phone
  2. Press Play on Node-RED, it doesn't play
  3. Press Play on the phone, and then stop on the phone
  4. Press Play on Node-RED, now it works

AND

  1. If I press Stop (either phone or Node-RED
  2. Then wait 2 minutes
  3. Play on Node-RED no longer works until I start and stop on the phone first.

It looks like the issue occurs only when the phone screen turns off.

I tested the same workflows using the web player on my laptop instead of the app on my phone, and the Node-RED play button starts the player. However, if I leave the web player paused for a longer time, then Node-RED no longer triggers play.

A useful diagnostic from the web player is that there is a button for selecting the playback device. Initially it showed both the phone and web player as options. If I turn the phone off, then eventually the list only shows the web player. If I wait even longer with the web player paused, eventually it shows no available playback devices (not even itself!)

So, I think that there is an issue with Spotify removing the devices.

I used the spotify node to fetch the playback devices. When the phone has been inactive for a while, it is not even listed in the devices returned via API.

I see that the device seems to have a permanent ID. Could I use the TransferPlayback to "re-awaken" the phone by ID and get the controls to respond again?