0
// 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?

Farya
  • 277
  • 3
  • 14
Kateryna
  • 81
  • 7

1 Answers1

0

TextureView has SurfaceTexture. You can use this function in the 5s loop:

Bitmap bitmap = SurfaceTexture.getBitmap([with,height])
I'm SuperMan
  • 653
  • 7
  • 20