Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling failing connections #22

Open
kevinrenskers opened this issue Apr 17, 2013 · 9 comments
Open

Handling failing connections #22

kevinrenskers opened this issue Apr 17, 2013 · 9 comments

Comments

@kevinrenskers
Copy link
Contributor

If you loose network connection mid-stream, audjustable sends AudioPlayerInternalStateError to the delegate. This is perfect, it means I can fall back to other streams.

On the other hand, if you try to connect to a stream while you already don't have network connection (as opposed to loosing it mid-stream) then we do NOT get AudioPlayerInternalStateError, instead we're stuck in AudioPlayerInternalStateWaitingForData forever.

I would guess that connecting to the stream should just fail immediately? And send the appropriate error?

@kevinrenskers
Copy link
Contributor Author

I've created a sample project showing the problem: https://github.com/kevinrenskers/AudjustableTest

As you can see in the viewcontroller, I have multiple datasources, when a source fails I want to fail over to the next one. When I kill the internet connection while playing datasource one, it doesn't fail over, it doesn't reach the end ("Reached last stream"). Instead it's forever stuck in AudioPlayerInternalStateWaitingForData.

@DarthNerdus
Copy link

@kevinrenskers Just curious if you ever devised a workaround to address this?

@kevinrenskers
Copy link
Contributor Author

Nope :(

@tumtumtum
Copy link
Owner

Not sure why I didn't notice this issue before. I'll look into it soon.

@tumtumtum
Copy link
Owner

I believe this is now fixed?

@kevinrenskers
Copy link
Contributor Author

Not really. I do sometimes get the AudioPlayerErrorDataNotFound when starting a stream when there's no internet, but not always. Sometimes it's still stuck in AudioPlayerInternalStateWaitingForData.

Also, when you loose the internet connection in the middle of the stream, you do get a AudioPlayerInternalStateError (via audioPlayer:internalStateChanged:), but NOT the AudioPlayerErrorDataNotFound (via audioPlayer:didEncounterError:). Not sure why an internal error isn't also made public?

Now my delegate has to implement both methods and listen to both error codes (AudioPlayerInternalStateError and AudioPlayerErrorDataNotFound) and handle fallbacks for both. Strange.

And like I said, the AudioPlayerErrorDataNotFound is not reliable, attempting to start a stream with no internet still often results in the audio player waiting forever.

I've updated the example app to use StreamingKit. If you could just play around with it, kill your internet connection at random times during/before a stream, you'll see the inconsistencies.

@tumtumtum
Copy link
Owner

Things are a bit complicated because of the async/gapless nature of the player. audioPlayerDidEncounterError is not a great callback because errors need to be associated with a specific queue item. It's currently only used for "critical" errors (like unable to allocate memory for the AudioQueue buffers etc) rather than errors related to playback. I'll have a think about how better to support error conditions.

@kojilab
Copy link

kojilab commented Mar 19, 2014

Is there a way to see if it's a networking problem using the library or should we just capture the error and then maybe see if there's a connection? Thanks

@alexfoxy
Copy link

@tumtumtum Did you work out a way to notify the user that there's no internet connection when they start playback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants