0

I am able to display the thumbnail for videoview from video by using following code,

MediaMetadataRetriever retriever = new MediaMetadataRetriever(); 
retriever.setDataSource(getApplicationContext(), uri);
Bitmap bmp = retriever.getFrameAtTime(2 * 1000000, MediaMetadataRetriever.OPTION_CLOSEST);
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bmp);
mVideoView.setBackground(bitmapDrawable);

But this mVideoView.setBackground(bitmapDrawable); method is available from version 4.1. How to do it for OS version below 4.1?

ravindra.kamble
  • 1,023
  • 3
  • 11
  • 20
  • Actually i'd tried your above code to get all frames from video file but i get only the first frames repeatedly.my duration of video is 127040(2:07sec) divided the video to 32 frames can view all 32 images but all were same images i'd tried a lot to fix it with getFrameAtTime(potions) but no use at all exactly i don't knoe where it goes wrong so can you help me by your full source code should i include any thing in AndroidManifest – Manoj May 21 '14 at 16:11

1 Answers1

2

See this question:

int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
    mVideoView.setBackgroundDrawable();
} else {
    mVideoView.setBackground();
}
Community
  • 1
  • 1
William Seemann
  • 3,440
  • 10
  • 44
  • 78