// Play video when the media source is ready for playback.
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaPlayer.start();
// mMediaPlayer.getDuration();
MediaMetadataRetriever mMMR = new MediaMetadataRetriever();
mMMR.setDataSource(FILE_NAME, new HashMap<String, String>());
String time = mMMR.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
Bitmap bitmap;
int fps = 24;
int deltaT= (int)1/fps;
for (int time_ms=1;time_ms<Integer.valueOf(time)*1000;time_ms+=24){
bitmap = mMMR.getFrameAtTime(5000);
if (bitmap==null) break;
}
}
});
I tried to connect MediaMetadataRetriever
but then the video is not played.
It is interesting how to implement it in an asynchronous way: video is playing and on the background we taking a picture for instance on 5 seconds of video?