2016-09-29 212 views
4

我在播放實時視頻(HLS)之後得到此異常,對於錄製的視頻,它工作正常。Exoplayer(2.0.0)在播放實時HLS視頻時給予BehindLiveWindowException

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) 

回答

6

根據谷歌版本2.0是非常不穩定的實時HLS播放。所以我不推薦現在切換到2.0的Live HLS播放。 即將到來的問題BehindLiveWindowException,Google仍在努力解決此問題,作爲Live HLS查找功能的一部分。在onError的再次 https://github.com/google/ExoPlayer/issues/1782

作爲一個臨時的解決辦法u能調用preparePlayer()():

請在這裏追蹤狀態。

@Ovierride 
public void onError(Exception e) { 

    if (e instanceof ExoPlaybackException 
      && e.getCause() instanceof BehindLiveWindowException) { 
     preparePlayer(true); 
    } 
}