spotify-web-playback-sdk-example icon indicating copy to clipboard operation
spotify-web-playback-sdk-example copied to clipboard

Please clarify life-cycle considerations of the Player object

Open stippi opened this issue 11 months ago • 4 comments

Hi,

First of all, thanks for making the SDK available and the great documentation and this example!! I was able the get everything working rather quickly. However, a few questions arise which I cannot find answers to anywhere:

When my Single Page Application is open for a longer time, the player connection (usually when idle, i.e. not streaming, but also sometimes when streaming) will become broken eventually. That means, even though I don't receive any "not ready" event from the player, I cannot start streaming again. Some of the symptoms will be (a random combination of them):

  • I will see "502 Bad Gateway" errors for the web socket in the log which seem to come from the Web Playback SDK Javascript.
  • Trying to start playback may produce a "404" which refers to the Device ID that the Player instance was assigned, as the device will no longer be in the device list on the server side.
  • Trying to call disconnect() on the Player instance will just hang.
  • Simply calling connect() again may be "successful", but the connection is actually still broken.

Please note that I periodically refresh the access token, and that I give the Player instance a callback implementation that will always use the current access token.

I am perfectly fine with the Player instance becoming stale after a while. What I need is a way to 1) become aware of it reliably (like by receiving the "not ready" event, and 2) being able to recover from that without reloading the page.

I also observed that multiple instances of my application may be registered at the Spotify servers concurrently. For example, when I reload the page, I get a new device ID, and the previous instance may still exist in the Spotify devices list.

Thanks a lot for any clarification!

stippi avatar Mar 01 '24 10:03 stippi