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

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
    }
}

Exoplayer offer advance implementation which media player do not.

in Advance example of Exoplayer by Android, in FullPlayerActivity.java they have implemented onStateChanged, which offers STATE_ENDED

You can download example from the right hand section of this page under term RELATED SAMPLES