0

I'm just trying to have my UI update when the stream stops due to a connectivity issue, but didencounterstreamingerror is not called when there is no connection. I know the delegate is setup properly because other playback delegate methods are called.

davis
  • 1,911
  • 6
  • 26
  • 50

1 Answers1

0

This is intended behaviour. -didEncounterStreamingError: is intended for times when the backend cannot deliver that track at all for some reason, and is very rare. You'll notice that the official Spotify clients don't error out either in this situation - they just pause and wait for the track to resume, while separately informing the user there's a problem with the connection.

The network connection being down isn't an error state - it's a temporary pause. In this situation, you should watch the connectionState on SPSession and inform the user that their connection is down. You application should mimic the official clients and resume playback as soon as audio data starts coming in again when a connection is restored.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Is there a good way to detect when streaming pauses because the buffer runs out due to network issues, etc? Perhaps through the SPPlaybackManager? – davis Feb 27 '14 at 01:00
  • If the audio pauses on its own and you don't get a play token lost message, it's because of bandwidth starvation. Otherwise, I pretty much described it in my answer - observe the `connectionState` property of your `SPSession`, and if playback pauses on its own while the connection state is offline, it's because of bandwidth starvation. – iKenndac Feb 27 '14 at 09:08
  • Ok, one more question and I'll stop bothering you. When the buffer runs out due to bandwidth starvation, the isPlaying property doesn't change. Is there anyway to detect when music is paused vs. still playing from the buffer in the event of a connection loss? – davis Mar 03 '14 at 03:45
  • Watch your buffer - if it's empty and you're not getting more data, you know. If you're using `SPPlaybackManager` you'll need to customise it, since that doesn't deal with this case. – iKenndac Mar 03 '14 at 09:10