2017-05-16 19 views
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; 
    } 
} 
}); 

MediaMetadataRetriever에 연결하려고했으나 비디오가 재생되지 않았습니다. 비동기 방식으로 구현하는 방법은 흥미 롭습니다. 비디오는 재생 중이고 백그라운드에서는 5 초짜리 비디오로 사진을 찍고 있습니까?구체적인 시간에 TextureView에서 비디오를 재생하는 것에서 프레임을 가져 오는 방법은 무엇입니까?

답변

0

TextureView에는 SurfaceTexture가 있습니다. 이 기능은 5 초 루프에서 사용할 수 있습니다.

Bitmap bitmap = SurfaceTexture.getBitmap([with,height])