Get Video Thumbnail from Uri

前端 未结 7 1240
遇见更好的自我
遇见更好的自我 2020-12-19 07:45

I want to select a video from my Gallery. It\'s working fine. But now I want to display a Bitmap, as a thumbnail.I tired this code it\'s not working, it always says: NullPoi

7条回答
  •  清歌不尽
    2020-12-19 08:39

    For API 27, for document URI (1000 is microseconds)

    MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    mmr.setDataSource( context, doc_uri );
    Bitmap bm = mmr.getScaledFrameAtTime( 1000, MediaMetadataRetriever.OPTION_NEXT_SYNC, 128, 128 );
    

提交回复
热议问题