I already got it to create a thumbnail from my video. The code looks like this:
videoGalleryThumbnails.add(ThumbnailUtils.extractThumbnail(ThumbnailUtils.cre
need little changes for this code:
try {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
//have to control the version for the setDataSource
if (Build.VERSION.SDK_INT >= 14)
retriever.setDataSource(video_path, new HashMap());
else
retriever.setDataSource(video_path);
int timeInSeconds = 5;
Bitmap thumb = retriever.getFrameAtTime(timeInSeconds * 1000000,
MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
imageViewThumb.setImageBitmap(thumb);
} catch (Exception ex) {
ex.printStackTrace();
}
if we don't control the version for "setDataSource" then we will get exceptions. for me it was not working until version controlling.