Search code examples
androidexoplayerandroid-media3

Prevent automatic jump to next playlist item in Android media3 Player


I created a MediaController, MediaSession and ExoPlayer with media3 jetpack for Android. Everything works fine!

For the context of the App I am building, the playlist should pause after a media item is played and not automatically jump to the next item and play it.

In detail I create a list of MediaItems and set them on the MediaController. Also the repeat mode is set as OFF (which doesn't repeat the whole playlist):

mediaController.setMediaItems(mediaItems);
mediaController.setRepeatMode(Player.REPEAT_MODE_OFF);

Is there a flag or another approach to pause the player after a media item reached it's end? In the context of my app the user should decide, if the next item should be played.


Solution

  • You can use ExoPlayer.setPauseAtEndOfMediaItems​(true).