I am using the Exoplayer Demo app and want to preload a MP4 video from SD card. I have tried out the implementation from this post, but it does not work. There is no such class
This worked for me.Try these steps:
Get path of the file and start the player
File myFile = new File(extStore.getAbsolutePath() + "/folder/videos/" + video_name);
videoUrl= String.valueOf(Uri.fromFile(myFile));
initializePlayer(videoUrl);
Initializing player
private void initializePlayer(String videoUrl) {
player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(getActivity()),
new DefaultTrackSelector(), new DefaultLoadControl());
playerView.setPlayer(player);
player.setPlayWhenReady(playWhenReady);
player.seekTo(currentWindow, playbackPosition);
Uri uri = Uri.parse(videoUrl);
MediaSource mediaSource = buildMediaSource(uri);
player.prepare(mediaSource, resetPositionBoolean, false);
}
Building media source
private MediaSource buildMediaSource(Uri uri) {
return new ExtractorMediaSource.Factory(
new DefaultDataSourceFactory(getActivity(),"Exoplayer-local")).
createMediaSource(uri);
}