how to get video thumb nail from raw folder video on android

大城市里の小女人 提交于 2019-12-01 04:40:06

You can try to get some frame out of your video just like this:

    Uri  videoURI = Uri.parse("android.resource://" + getPackageName() +"/"
            +R.raw.cashword_video);
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(this, videoURI);
    Bitmap bitmap = retriever
          .getFrameAtTime(100000,MediaMetadataRetriever.OPTION_PREVIOUS_SYNC);
    Drawable drawable = new BitmapDrawable(getResources(), bitmap);

Video on res/raw folder of your application aren't managed by Android Media Content Provider, so you cannot obtain their thumbnail from it.

Alternatively, you can try to save them as normal file in your SD and, then, ask to media provider for thumbnail or create it directly via ThumbnailUtils.createVideoThumbnail class (only Android 2.2 or above)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!