Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Creating video thumbnails from Video URI

I'm budiling an application and it lists all the videos i recorded using the recorder in a list. Is it possible for me to create a thumbnail with the help of Uri instead of the string???

my current code goes as below but it no longer works as my input to the constructor is Uri not string.

bmThumbnail = ThumbnailUtils.createVideoThumbnail(
                    (db_results.get(position)), Thumbnails.MICRO_KIND);
            imageThumbnail.setImageBitmap(bmThumbnail);

I'm returned the error

The method createVideoThumbnail(String, int) in the type ThumbnailUtils is not applicable for the arguments (Uri, int)

Thanks for your time in advance.

like image 722
Jay Mayu Avatar asked Aug 08 '11 04:08

Jay Mayu


People also ask

How do I get the thumbnail from a video URI?

Bitmap thumb = ThumbnailUtils. createVideoThumbnail(filePath, Thumbnails. MINI_KIND);

How do I make a thumbnail from a video clip?

Making a video thumbnail is relatively straightforward. You can take a screenshot from your video that best explains its contents, or you can use a tool like Photoshop or Canva to overlay text or icons on the image. To make a screen capture on a PC, use the Windows Snipping Tool.

Which tool is used to display the thumbnail of a video in Android?

Many of the application are using the Glide library for loading the Image and Video thumbnail. You can download the Glide Library from here and alternatively, you can include the library directly in your app using Gradle.


1 Answers

public String getRealPathFromURI(Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(contentUri, proj, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
like image 115
Bogdan M. Avatar answered Sep 24 '22 20:09

Bogdan M.