android.provider.MediaStore.Video.Thumbnails Java Examples

The following examples show how to use android.provider.MediaStore.Video.Thumbnails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideosListAdapter.java    From GifAssistant with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder holder = null;
	if (convertView == null) {
		holder=new ViewHolder();  
		convertView = mInflater.inflate(R.layout.videos_list_item, null);
		holder.thumb = (ImageView)convertView.findViewById(R.id.video_thumb);
		holder.name = (TextView)convertView.findViewById(R.id.video_name);
		holder.time = (TextView)convertView.findViewById(R.id.video_file_created_time);
		holder.duration = (TextView) convertView.findViewById(R.id.video_total_duration);
		convertView.setTag(holder);
	}else {
		logd("convertView != null, reuse");
		holder = (ViewHolder)convertView.getTag();
	}
	
	VideosInfo videoInfo = new VideosInfo(mVideosPaths.get(position));
	//holder.thumb.setImageBitmap(ExtractPicturesWorker.extractBitmap(mVideosPaths.get(position), 0));
	holder.thumb.setImageBitmap(ThumbnailUtils.createVideoThumbnail(mVideosPaths.get(position), Thumbnails.MINI_KIND));
	holder.name.setText("文件名:" + videoInfo.getName());
	holder.time.setText("时间:" + videoInfo.getLastModifyTime());
	holder.duration.setText("时长:" + videoInfo.getDuration());

	return convertView;
}
 
Example #2
Source File: GalleryCache.java    From MediaChooser with Apache License 2.0 6 votes vote down vote up
@Override
protected Bitmap doInBackground(Void... params) {
    Bitmap bitmap = null;
    try {
        bitmap = ThumbnailUtils.createVideoThumbnail(mImageKey, Thumbnails.FULL_SCREEN_KIND);

        if (bitmap != null) {
            bitmap = Bitmap.createScaledBitmap(bitmap, mMaxWidth, mMaxWidth, false);
            addBitmapToCache(mImageKey, bitmap);
            return bitmap;
        }
        return null;
    } catch (Exception e) {
        if (e != null) {
            e.printStackTrace();
        }
        return null;
    }
}
 
Example #3
Source File: GalleryCache.java    From MediaChooser with Apache License 2.0 6 votes vote down vote up
@Override
protected Bitmap doInBackground(Void... params) {
    Bitmap bitmap = null;
    try {
        bitmap = ThumbnailUtils.createVideoThumbnail(mImageKey, Thumbnails.FULL_SCREEN_KIND);

        if (bitmap != null) {
            bitmap = Bitmap.createScaledBitmap(bitmap, mMaxWidth, mMaxWidth, false);
            addBitmapToCache(mImageKey, bitmap);
            return bitmap;
        }
        return null;
    } catch (Exception e) {
        if (e != null) {
            e.printStackTrace();
        }
        return null;
    }
}
 
Example #4
Source File: GalleryCache.java    From MediaChooser with Apache License 2.0 6 votes vote down vote up
@Override
protected Bitmap doInBackground(Void... params) {
	Bitmap bitmap = null;
	try {
		bitmap = ThumbnailUtils.createVideoThumbnail(mImageKey, Thumbnails.FULL_SCREEN_KIND);

		if (bitmap != null) {
			bitmap = Bitmap.createScaledBitmap(bitmap, mMaxWidth, mMaxWidth, false);
			addBitmapToCache(mImageKey, bitmap);
			return bitmap;
		}
		return null;
	} catch (Exception e) {
		if (e != null) {
			e.printStackTrace();
		}
		return null;
	}
}
 
Example #5
Source File: BaseImageDownloader.java    From letv with Apache License 2.0 5 votes vote down vote up
protected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException {
    ContentResolver res = this.context.getContentResolver();
    Uri uri = Uri.parse(imageUri);
    if (isVideoUri(uri)) {
        Bitmap bitmap = Thumbnails.getThumbnail(res, Long.valueOf(uri.getLastPathSegment()).longValue(), 1, null);
        if (bitmap != null) {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bitmap.compress(CompressFormat.PNG, 0, bos);
            return new ByteArrayInputStream(bos.toByteArray());
        }
    } else if (imageUri.startsWith(CONTENT_CONTACTS_URI_PREFIX)) {
        return Contacts.openContactPhotoInputStream(res, uri);
    }
    return res.openInputStream(uri);
}
 
Example #6
Source File: VideoCaptureActivity.java    From VideoCamera with Apache License 2.0 5 votes vote down vote up
public Bitmap getVideoThumbnail() {
    final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(mVideoFile.getFullPath(),
            Thumbnails.FULL_SCREEN_KIND);
    if (thumbnail == null) {
        CLog.d(CLog.ACTIVITY, "Failed to generate video preview");
    }
    return thumbnail;
}
 
Example #7
Source File: CMImageLoader.java    From GreenDamFileExploere with Apache License 2.0 5 votes vote down vote up
/**
 * 获取视频图像
 * 
 * @param videoPath
 * @return
 */
public static Bitmap getVideoThumbnail(String videoPath) {
    Bitmap bitmap = null;
    bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, Thumbnails.MINI_KIND);
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, 100, 100, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
    return bitmap;
}
 
Example #8
Source File: VideoCaptureActivity.java    From LandscapeVideoCamera with Apache License 2.0 5 votes vote down vote up
public Bitmap getVideoThumbnail() {
    final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(mVideoFile.getFullPath(),
            Thumbnails.FULL_SCREEN_KIND);
    if (thumbnail == null) {
        CLog.d(CLog.ACTIVITY, "Failed to generate video preview");
    }
    return thumbnail;
}
 
Example #9
Source File: CaptureDemoFragment.java    From VideoCamera with Apache License 2.0 4 votes vote down vote up
private Bitmap getThumbnail() {
    if (filename == null) return null;
    return ThumbnailUtils.createVideoThumbnail(filename, Thumbnails.FULL_SCREEN_KIND);
}
 
Example #10
Source File: AsyncImageLoader.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
public static Bitmap loadImageFromFilePath(String filePath) {
	return ThumbnailUtils.createVideoThumbnail(filePath,
			Thumbnails.MICRO_KIND);
}
 
Example #11
Source File: ImageResizer.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Bitmap processBitmap(Object data) {
	
	String filePath=String.valueOf(data);
	return ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);
}
 
Example #12
Source File: CaptureDemoFragment.java    From LandscapeVideoCamera with Apache License 2.0 4 votes vote down vote up
private Bitmap getThumbnail() {
    if (filename == null) return null;
    return ThumbnailUtils.createVideoThumbnail(filename, Thumbnails.FULL_SCREEN_KIND);
}