android - How to create thumbnails for videos from sd card.? -


i'm new android development, , i'm listing videos storage(my mobile) , want create thumbnail display in custom listview. my problem when creating thumbnail it's taking time, how solve ? please me out.

below code create thumbnail

@override protected void oncreate(bundle savedinstancestate){     super.oncreate(savedinstancestate);     setcontentview(r.layout.video_list);      listview videolist=(listview)findviewbyid(r.id.video_list);     arraylist<string> videoname = new arraylist<>();     final arraylist<string> videopath = new arraylist<>();     arraylist<bitmap> videothumbnail = new arraylist<>();      string selection =mediastore.video.media._id;     string[] columns = { mediastore.video.media.data,mediastore.video.media.display_name};      cursor cursor = getcontentresolver().query(mediastore.video.media.external_content_uri,             columns, selection, null, null);      while (cursor.movetonext()){          bitmap bmthumbnail;         bmthumbnail = thumbnailutils.createvideothumbnail(string.valueof(uri.parse(cursor.getstring(cursor.getcolumnindex(mediastore.video.media.data)))),                 mediastore.video.thumbnails.micro_kind);         videoname.add(cursor.getstring(cursor.getcolumnindexorthrow(mediastore.video.media.display_name)));         videopath.add(string.valueof(uri.parse(cursor.getstring(cursor.getcolumnindex(mediastore.video.media.data)))));         videothumbnail.add(bmthumbnail);     }     cursor.close();     toast.maketext(getapplicationcontext(), ""+videothumbnail.size(), toast.length_long).show();      videoadapter videoadapter = new videoadapter(this, videoname,videothumbnail);     videolist.setadapter(videoadapter); 

add following library gradle :

compile 'com.github.bumptech.glide:glide:3.6.1' 

then in code :

glide.with(context)                 .load(uri_of_your_video)                 .placeholder(r.drawable.ic_video_place_holder)                 .into(imageview); 

it's smooth , cache image.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -