Java tutorial
//package com.java2s; import java.io.File; import android.content.Context; import android.graphics.Bitmap; import android.media.MediaMetadataRetriever; import android.text.TextUtils; public class Main { public static Bitmap getVideoScreenshotBitmap(Context context, String videoPath) { if (TextUtils.isEmpty(videoPath) || !new File(videoPath).exists()) { return null; } Bitmap bitmap = null; MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); mediaMetadataRetriever.setDataSource(videoPath); bitmap = mediaMetadataRetriever.getFrameAtTime(0); return bitmap; } /** * Returns true if the string is null or 0-length. * * @param str * the string to be examined * @return true if str is null or zero length */ public static boolean isEmpty(CharSequence str) { if (str == null || str.length() == 0 || "null".equals(str.toString().trim())) return true; else return false; } }