Search code examples
androidmedia-playerandroid-mediaplayerandroid-video-playerexoplayer

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


Has anyone tried using ExoPlayer to achieve this? I tried looking online with no success.

When I say gapless playback, I am referring to the problem of using the media player to play local videos back to back. After the first video is done playing, there is a noticeable delay of 1 second before the second video starts.

Hoping this question helps in understanding this issue further. For reference please look at the following question:

Android: MediaPlayer gapless or seamless Video Playing


Solution

  • 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);