7

在播放实时视频(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)
4

1 回答 1

14

根据 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);
    }
 }
于 2016-10-04T11:42:49.213 回答