get Video Thumbnail - Android Graphics

Android examples for Graphics:Bitmap Thumbnail

Description

get Video Thumbnail

Demo Code


//package com.java2s;
import android.graphics.Bitmap;

import android.media.ThumbnailUtils;

public class Main {

    public static Bitmap getVideoThumbnail(String videoPath, int width,
            int height, int kind) throws Exception {
        Bitmap bitmap = null;//www  .  j a  va  2  s.c  o  m

        bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, kind);
        if (width * height == 0) {
            bitmap = ThumbnailUtils.extractThumbnail(bitmap,
                    bitmap.getWidth(), bitmap.getHeight(),
                    ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
        } else {
            bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
                    ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
        }
        return bitmap;
    }
}

Related Tutorials