How to get thumbnail for video in my /sdcard/Android/data/mypackage/files folder?

后端 未结 12 1715
情深已故
情深已故 2020-11-30 22:21

Query to MediaStore.Video.Media.EXTERNAL_CONTENT_URI returns only video in /sdcard/DCIM/100MEDIA

But I want to get thumbnails for video in

12条回答
  •  粉色の甜心
    2020-11-30 23:10

    If you are directly creating thumbnails as follows

    Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path,
        MediaStore.Images.Thumbnails.MINI_KIND);
    

    Then there is a problem with this method if your are creating thumbnails for large video set(for large number of videos). the application will freeze until all the thumbnails are loaded because all the process are executing in the main thread.


    Use SuziLoader

    This loader will load the thumbnails for the videos which is locally stored on your filesystem in background.

    String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/video.mp4";
    ImageView mThumbnail = (ImageView) findViewById(R.id.thumbnail);
    
    SuziLoader loader = new SuziLoader(); //Create it for once
    loader.with(MainActivity.this) //Context
        .load(path) //Video path
        .into(mThumbnail) // imageview to load the thumbnail
        .type("mini") // mini or micro
        .show(); // to show the thumbnail
    

    To get this dependency use the following steps

    Step 1. Add the JitPack repository to your build file
    Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    

    Step 2. Add the dependency

    dependencies {
        compile 'com.github.sushinpv:SuziVideoThumbnailLoader:0.1.0'
    }
    

    ADD READ EXTERNAL STORAGE Permission in manifest

    
    

提交回复
热议问题