I am developing a DASH client for Android and am testing the playback multiple video segments in mp4 format on Android. Therefore I tried two approaches so far:
using VideoView:
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.setVisibility(View.VISIBLE);
videoView.start();
}
});
using TextureView:
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});
mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
try {
mMediaPlayer.setSurface(surface);
mMediaPlayer.reset();
mMediaPlayer.setDataSource(file.getAbsolutePath());
mMediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
});
Okay both work but have a little lag when switching to the next file. What can cause that? Am I doing something wrong and can improve the code? I read about using the MediaExtractor and MediaCodec APIs for better playback of multiple videos which were also improved for DASH compatibility with Android verisons 4.3 and 4.4 but I haven't understood yet how to use them to play video and audio on a surface. I can only find sources on how to us them in order to play video or audio.
I hope somebody can help me to play multiple video segments in succession seamlessly.