just_audio
just_audio copied to clipboard
Audio Processing state is ready when internet is off while streaming
Describe the bug When streaming content from a CDN (Cloudfront), I see that when the internet is turned off the state changes to buffering for a brief second and then changes to ready at this point, I receive no audio. audio_serivce: 0.9.0 and just_audio 0.2.1 Minimal reproduction project I think you can reproduce it with the example project.
To Reproduce Steps to reproduce the behaviour:
- Play a considerably large audio file.
- Turn off the internet when the audio starts playing.
- Seek to random positions on a seek bar to make it buffer.
Error messages
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(0, com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect, null)
Expected behaviour A state suiting to these events would make sense, either keep the buffering state or emit an error state.
Smartphone (please complete the following information):
- Device: One Plus 5T
- OS: Android 10
Flutter SDK version
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.3 19D76, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2018.3.6)
[✓] VS Code (version 1.46.0)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Hi @alakhsingh
All ExoPlayer errors are passed on to the Flutter side through the stream. I would expect you can listen to these and detect this sort of error, but I can't reproduce without a reproduction project.
Hi @ryanheise, Thank you for replying. I used the example project, ran on One Plus 5T phone to reproduce the issue. Steps followed:
- Press AudioPlayer.
- When the audio starts streaming, turn off wifi and mobile data.
- Seek to a random position towards the end, check the logs. You should see
E/flutter (13848): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(0, com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect, null)
. I know that the reason the position keeps updating which make it look like the audio is playing is because the state emits ready. I also know that this happens becausefinal bufferingState = event.buffering ? AudioProcessingState.buffering : null;
event.buffering is false after that exception.
Yes, for now, I am trying to work through by detecting from the stream but having a state with respect to these errors or at least skipping to next rather than just playing might be a better way in my opinion.
Thanks, Alakh
The future plan is to make the state model more closely resemble ExoPlayer's state model, although it doesn't have an error state. Certainly also the position stream should stop emitting in this case, even if there isn't an error state.
yes i also need 404 state.. if url error..nothing happend no state received.. but exoplayer throw error
@naguchennai as mentioned, all asynchronous ExoPlayer errors are emitted on the event stream, while all synchronous errors can be caught on setUrl
. There are some improvements that could be made to the state but the errors should be available.
@Naguchennai , @ryanheise
Any luck with this issue? I am experiencing same issue as well. When I put phone deliberately in Airplane mode, it throws error ( if it's done before the load then I can catch in "await player.load()", and if it's done while audio is still buffering then I can catch it in playbackEventStream ), but when I turn off "Mobile Data" and "Wifi" from the control center ( as opposed to putting phone in AirPlane mode ), it doesn't throw any error in playbackEventStream. And position stream keeps getting updated.
just_audio: 0.9.28 audio_session: ^0.1.10 audio_service: ^0.18.7
@ArkeshGKalathiya the answer would be different depending on whether you are using a proxy-based feature. E.g. headers, or caching, or StreamAudioSource. If you are using a proxy-based feature, then it will be harder to solve and I would need a proper minimal reproduction project and reproduction steps. Can you confirm this happens with the official example?
@ryanheise
I think the issue was setAutomaticallyWaitsToMinimizeStalling set to false, but I will test this thoroughly and will get back either way.
Btw , I am using combination of asset and uri audio in ConcatenatingAudioSource, so no headers/caching/StreamAudioSource
Any update on this? I'm experiencing the same issue. I can't seem to catch the errors from the audio player when I turn off internet access.
@EvanSmith93 all updates are completely public in the comments above. See my comment/question from 3 comments back, and if you would like to provide an update to that question, you are welcome.