我在播放实时视频 (HLS) 一段时间后收到此异常,对于录制的视频,它工作正常。
com.google.android.exoplayer2.source.BehindLiveWindowException
at com.google.android.exoplayer2.source.hls.HlsChunkSource.getNextChunk(HlsChunkSource.java:255)
at com.google.android.exoplayer2.source.hls.HlsSampleStreamWrapper.continueLoading(HlsSampleStreamWrapper.java:313)
at com.google.android.exoplayer2.source.CompositeSequenceableLoader.continueLoading(CompositeSequenceableLoader.java:55)
at com.google.android.exoplayer2.source.hls.HlsMediaPeriod.continueLoading(HlsMediaPeriod.java:198)
at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeContinueLoading(ExoPlayerImplInternal.java:1080)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleContinueLoadingRequested(ExoPlayerImplInternal.java:1067)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:289)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer2.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
最佳答案
根据 Google 的说法,2.0 版对于 Live HLS 播放来说非常不稳定。所以我不建议现在切换到 2.0 进行 Live HLS 播放。 关于您的 BehindLiveWindowException 问题,Google 仍在努力解决此问题,作为 Live HLS 搜索功能的一部分。
请在此处跟踪状态: https://github.com/google/ExoPlayer/issues/1782
作为临时修复,您可以在 onError() 中再次调用 preparePlayer()。
@Ovierride
public void onError(Exception e) {
if (e instanceof ExoPlaybackException
&& e.getCause() instanceof BehindLiveWindowException) {
preparePlayer(true);
}
}
关于android - Exoplayer(2.0.0) 在播放实时 HLS 视频时给出 BehindLiveWindowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39770033/