ExoPlayer, Loop Ended / Started LoopingMediaSource listener

I am using ExoPlayer to play a video in a loop, but before the original video is triggered in each loop, I need to reset some states of my layout. I know that ExoPlayer calls onPlayerStateChanged with ExoPlayer.STATE_ENDED when video ends for normal MediaSources, but it is not called for LoopingMediaSource.

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    if (playbackState == ExoPlayer.STATE_ENDED) {
        showControls();
        resetLayoutStates(); //I need it here, even in LoopingMediaSource
    }
    updateButtonVisibilities();
}

      

Does Exoplayer have a callback when the source is reloaded or terminated in a loop? Or does he have some workaround for my situation?

+3


source to share


1 answer


Every time the video ends playing, a loop is called EventListener.onPositionDiscontinuity()

. There you can call SimpleExoPlayer#getCurrentWindowIndex()

to get the current window index, which will basically tell you how many time loops have played.



0


source







All Articles