No matter what I try, I am not able to catch "ExoPlaybackException: Source error" error. The video playback stops and I can see Exoplayer error thrown. The Stacktrace is below:
2021-02-09 22:36:51.917 27876-19080/com.... E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:554)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:237)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.source.BehindLiveWindowException
at com.google.android.exoplayer2.source.hls.HlsChunkSource.getNextChunk(HlsChunkSource.java:308)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.continueLoading(HlsSampleStreamWrapper.java:662)
at com.google.android.exoplayer2.source.CompositeSequenceableLoader.continueLoading(CompositeSequenceableLoader.java:80)
at com.google.android.exoplayer2.source.hls.HlsMediaPeriod.continueLoading(HlsMediaPeriod.java:365)
at com.google.android.exoplayer2.source.MaskingMediaPeriod.continueLoading(MaskingMediaPeriod.java:219)
at com.google.android.exoplayer2.MediaPeriodHolder.continueLoading(MediaPeriodHolder.java:218)
at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeContinueLoading(ExoPlayerImplInternal.java:2011)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleContinueLoadingRequested(ExoPlayerImplInternal.java:1992)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:489)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:237)
at android.os.HandlerThread.run(HandlerThread.java:67)
This is my "onPlayerError" method, but it does not seem to be called for some reason.
private class PlayerEventListener implements Player.EventListener {
...
@Override
public void onPlayerError(ExoPlaybackException error) {
switch (error.type) {
case ExoPlaybackException.TYPE_SOURCE:
Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
break;
case ExoPlaybackException.TYPE_RENDERER:
Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
break;
case ExoPlaybackException.TYPE_UNEXPECTED:
Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
break;
}
}
...
}
player.addListener(new PlayerEventListener());
Am I missing anything?
Not sure where I was looking... but the error seems to be caught in the "onPlayerError()" method.
It is caught right here:
switch (error.type) {
case ExoPlaybackException.TYPE_SOURCE:
Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
//Restart the playback
play(mediaItem);
break;
Currently, I am handling the error in a way that I restart the playback.
Additional Information.
In customer product, when sharing the screen on the web, only the video track was recorded, without audio, into HLS format. Because of this, on iOS with AVPlayer, and on Android with ExoPlayer v2.18, and on Flutter with VideoPlayer v2.4.8, there was an error:
com.google.android.exoplayer2.ExoPlaybackException: Source error
The problem was fixed by adding a silent audio track when recording.
key moment: hls must contain 2 tracks at the same time: audio and video
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With