I want to create my own gallery to display all the images and videos (along with the duration) in the SD card. I use the following code to create a custom gallery
Code:
final String[] columns = { MediaStore.Images.Media.DATA ,MediaStore.Images.Media._ID}; final String orderBy = MediaStore.Images.Media.DATE_TAKEN; Cursor imagecursor = getContentResolver().query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, null, orderBy + " DESC"); this.imageUrls = new ArrayList<String>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); imageUrls.add(imagecursor.getString(dataColumnIndex)); } String[] parameters = { MediaStore.Video.Media._ID, MediaStore.Video.Media.DATA, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DURATION, MediaStore.Video.Media.DATE_TAKEN,MediaStore.Video.Thumbnails.DATA}; Cursor videocursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, parameters, null, null, null); for (int i = 0; i < videocursor.getCount(); i++) { videocursor.moveToPosition(i); imageUrls.add(videocursor.getString(videocursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA))); } options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.stub_image) .showImageForEmptyUri(R.drawable.image_for_empty_url) .cacheInMemory() .cacheOnDisc() .build(); imageAdapter = new ImageAdapter(this, imageUrls);
from the above code I can get the path to the video, how can I get the thumbnail of the video along with the duration of the video. and submit it to the gallery
if there are any projects in projects for your own gallery with videos and images, please post links I really want to create my own gallery to select several image and video files. I searched a lot on google, I find my own image gallery, but not with the video, please help me in solving this problem.
source share