How to implement oncompletionlistener to detect end of media file in Exoplayer

user2949215 picture user2949215 · Dec 8, 2014 · Viewed 26.6k times · Source

I am trying to play videos in the form of a playlist one after the other. I am using android Exoplayer to play my files, but there are no listeners in mediaplayer to listen to an end of the media file. Is there a way to listen to the end of media file using exoplayer.

Answer

Joe Maher picture Joe Maher · Feb 11, 2016

I know this is old, but just to expand on the accepted answer:

exoPlayer.addListener(this);

.....

@Override
public void onPlayerStateChanged(boolean playWhenReady, int state) {

    if (state == ExoPlayer.STATE_ENDED){
        //player back ended
    }
}