I am building an app that is successfully displaying an MP4 video file onButtonClick. I want to pre-buffer or preload the video's URI (remote url) so that it doesn't delay the playing of the video once the button is clicked. I want it to click and play right away, so pre-loading or buffering on the app launch splash screen seems like a fitting solution. Only thing is I don't know how. I have tons of Android Books, but hardly any of them cover buffering at all or they only cover audio.
Can anyone let me know how to buffer the video on a previous activity?
Thanks.
Google released ExoPlayer which provides a higher level for media playing : http://developer.android.com/guide/topics/media/exoplayer.html
It supports different state such as buffering in background :
// 1. Instantiate the player.
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
// 2. Construct renderers.
MediaCodecVideoTrackRenderer videoRenderer = …
MediaCodecAudioTrackRenderer audioRenderer = ...
// 3. Inject the renderers through prepare.
player.prepare(videoRenderer, audioRenderer);
I used it in my own project and it seems pretty efficient. Also Google made a Full Demo of the player : https://github.com/google/ExoPlayer/tree/master/demo/src/main/java/com/google/android/exoplayer/demo/full which is more powerfull than simple demo.