Android ExoPlayer : Does it solve gapless / seamless playback issue that is broken for the Android Media Player Android ExoPlayer : Does it solve gapless / seamless playback issue that is broken for the Android Media Player android android

Android ExoPlayer : Does it solve gapless / seamless playback issue that is broken for the Android Media Player


EDIT: ExoPlayer 2 supports gapless playback, but as of the time of writing is still unreleased as a stable version.

You will most likely never be able to achieve perfect gapless playback of multiple tracks with ExoPlayer or Android Media Player. Neither have been written to support starting multiple tracks and I imagine it will stay out of scope for both of them.

You can achieve gapless playback by using 2 different player instances, once you have started and played the first, you can load the second and start playback once the first finishes. Using this method you could have a gapless solution, as long as you prepare the second video during playback of the first.

To take it further, you can also use 2 different surface textures for rendering the multiple videos, once the first video reaches the end you could fade out the texture and fade in the new one. Resulting in a nice seamless video effect.

Because of the nature of playing multiple videos at once you will most likely want to create your own timer for incrementing the time and deciding when to switch to the next video, rather than trying to use the callbacks from ExoPlayer or Android Media. This will allow you to keep track of the time in a more accurate fashion, without needing to keep talking to multiple video codecs.


ExoPlayer 2, which is now officially released, seems to support gapless playback using the ConcatenatingMediaSource class. From its developer guide:

Transitions between sources are seamless. There is no requirement that the sources being concatenated are of the same format (e.g. it’s fine to concatenate a video file containing 480p H264 with one that contains 720p VP9). The sources may even be of different types (e.g. it’s fine to concatenate a video with an audio only stream).

And the example code:

MediaSource firstSource = new ExtractorMediaSource(firstVideoUri, ...);MediaSource secondSource = new ExtractorMediaSource(secondVideoUri, ...);// Plays the first video, then the second video.ConcatenatingMediaSource concatenatedSource =    new ConcatenatingMediaSource(firstSource, secondSource);


I know this is not the answer you've been looking for, but it's the only reasonable answer. The sole way to ensure no gaps in playback is to download the entire file first and begin playback when it's done. Otherwise, in the event that you lose connectivity before the file is finished downloading, pausing is inescapable.