Yes you can do that with OnCompletionListener:
mPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// do something when the end of a media source
// has been reached during playback.
}
});