librespot-java
librespot-java copied to clipboard
changes to prevent advance when queue is empty
One of my use cases plays a track from a list on demand without filling the spotify queue. Currently librespot-java will throw an exception when reaching the end of the queue and attempt to reload the current track as if it is the head of the queue. This causes a number of issues.
- An exception every time the end of the queue is reached.
- A reload of the metadata for the existing track, which often does not complete before the next track is added.
- Race conditions on the reload, and multiple playbackEnded messages on the websocket.
While I've been using elaborate error handling on my client app to resolve these problems, it often results in skipped tracks or no track loaded. These two changes attempt to prevent the loop back to the same track when the queue ends.