android - How to show all video thumbnails stored in a specific folder in sd card -
i getting bitmaps mediastore this
public class videostoredinsdcard extends activity { private cursor videocursor; private int videocolumnindex; listview videolist; int count; string thumbpath; string[] thumbcolumns = { mediastore.video.thumbnails.data,mediastore.video.thumbnails.video_id }; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); initialization(); } private void initialization() { system.gc(); string[] videoprojection = { mediastore.video.media._id,mediastore.video.media.data, mediastore.video.media.display_name,mediastore.video.media.size }; videocursor = managedquery(mediastore.video.media.external_content_uri,videoprojection, null, null, null); count = videocursor.getcount(); videolist = (listview) findviewbyid(r.id.phonevideolist); videolist.setadapter(new videolistadapter(this.getapplicationcontext())); videolist.setonitemclicklistener(videogridlistener); } private onitemclicklistener videogridlistener = new onitemclicklistener() { public void onitemclick(adapterview parent, view v, int position,long id) { system.gc(); videocolumnindex = videocursor.getcolumnindexorthrow(mediastore.video.media.data); videocursor.movetoposition(position); string filename = videocursor.getstring(videocolumnindex); log.i("filename: ", filename); //intent intent = new intent(videoactivity.this, viewvideo.class); //intent.putextra("videofilename", filename); //startactivity(intent); }}; public class videolistadapter extends baseadapter { private context vcontext; int layoutresourceid; public videolistadapter(context c) { vcontext = c; } public int getcount() { return videocursor.getcount(); } public object getitem(int position) { return position; } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { view listitemrow = null; listitemrow = layoutinflater.from(vcontext).inflate(r.layout.listitem, parent, false); textview txttitle = (textview)listitemrow.findviewbyid(r.id.txttitle); textview txtsize = (textview)listitemrow.findviewbyid(r.id.txtsize); imageview thumbimage = (imageview)listitemrow.findviewbyid(r.id.imgicon); videocolumnindex = videocursor.getcolumnindexorthrow(mediastore.video.media.display_name); videocursor.movetoposition(position); txttitle.settext(videocursor.getstring(videocolumnindex)); videocolumnindex = videocursor.getcolumnindexorthrow(mediastore.video.media.size); videocursor.movetoposition(position); txtsize.settext(" size(kb):" + videocursor.getstring(videocolumnindex)); int videoid = videocursor.getint(videocursor.getcolumnindexorthrow(mediastore.video.media._id)); cursor videothumbnailcursor = managedquery(mediastore.video.thumbnails.external_content_uri, thumbcolumns, mediastore.video.thumbnails.video_id+ "=" + videoid, null, null); if (videothumbnailcursor.movetofirst()) { thumbpath = videothumbnailcursor.getstring(videothumbnailcursor.getcolumnindex(mediastore.video.thumbna ils.data)); log.i("thumbpath: ",thumbpath); } thumbimage.setimageuri(uri.parse(thumbpath)); return listitemrow; } } }
how thumbnails specific folder in sd card. using tutorial http://gypsynight.wordpress.com/2012/02/17/how-to-show-all-video-file-stored-in-your-sd-card-in-a-listview/
it can done way:
int videoid = videocursor.getint(videocursor.getcolumnindexorthrow(mediastore.video.media._id)); contentresolver cr = getcontentresolver(); bitmapfactory.options options=new bitmapfactory.options(); options.insamplesize = 1; bitmap curthumb = mediastore.video.thumbnails.getthumbnail(cr, videoid, mediastore.video.thumbnails.micro_kind, options); thumbimage.setimagebitmap(curthumb);
Comments
Post a Comment