本文整理汇总了Java中android.provider.MediaStore.Video.Thumbnails类的典型用法代码示例。如果您正苦于以下问题:Java Thumbnails类的具体用法?Java Thumbnails怎么用?Java Thumbnails使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Thumbnails类属于android.provider.MediaStore.Video包,在下文中一共展示了Thumbnails类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@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;
}
}
示例2: getStreamFromContent
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
protected InputStream getStreamFromContent(String imageUri, Object extra) throws
FileNotFoundException {
ContentResolver res = this.context.getContentResolver();
Uri uri = Uri.parse(imageUri);
if (isVideoContentUri(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 getContactPhotoStream(uri);
}
return res.openInputStream(uri);
}
示例3: getView
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@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;
}
示例4: getVideoThumbnail
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
/**
* 获取视频图像
*
* @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;
}
示例5: doInBackground
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@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;
}
}
示例6: getStreamFromContent
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
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);
}
示例7: getVideoThumbnail
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
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;
}
示例8: createPreviewImage
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
private String createPreviewImage() throws IOException {
previewImage = null;
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath,
Thumbnails.FULL_SCREEN_KIND);
if (bitmap != null) {
previewImage = foldername + File.separator
+ Calendar.getInstance().getTimeInMillis() + ".jpg";
File file = new File(previewImage);
FileOutputStream stream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
}
return previewImage;
}
示例9: createThumbnailOfVideo
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
private String createThumbnailOfVideo() throws IOException {
String thumbnailPath = null;
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath,
Thumbnails.MINI_KIND);
if (bitmap != null) {
thumbnailPath = foldername + File.separator
+ Calendar.getInstance().getTimeInMillis() + ".jpg";
File file = new File(thumbnailPath);
FileOutputStream stream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
}
return thumbnailPath;
}
示例10: doInBackground
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@Override
protected Drawable doInBackground(Void... params)
{
Drawable drawable = null;
Bitmap bitmap = null;
ContentResolver contentResolver = imageView.getContext().getContentResolver();
if (media.isVideo()) {
bitmap = MediaStore.Video.Thumbnails.getThumbnail(contentResolver, media.getId(),
MediaStore.Video.Thumbnails.MINI_KIND, null);
if (bitmap == null) { // can`t get thumb from media database, use
// thumb
if (media.isVideo()) {
bitmap = ThumbnailUtils.createVideoThumbnail(media.getPath(), Thumbnails.MINI_KIND);
}
}
} else {
bitmap = ImageUtils.decodeBitmapFromFile(media.getPath(), imageView.getWidth(), imageView.getHeight());
}
if (bitmap != null) {
drawable = new BitmapDrawable(res, bitmap);
}
return drawable;
}
示例11: onCreateView
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.v("Create:::", "onCreateView called");
View rootView = inflater.inflate(R.layout.video_fragment, container,
false);
set=(Button) rootView.findViewById(R.id.button_set_alarm);
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
startActivity(new Intent(getActivity(),SetAlarmActivity.class));
}
});
mVideoView = (VideoView) rootView.findViewById(R.id.shouye_video_view);
mVideoView.setOnTouchListener(this);
mVideoView.setOnCompletionListener(this);
MediaController mc = new MediaController(this.getActivity());
mc.setVisibility(View.INVISIBLE);
mVideoView.setMediaController(mc);
String path = "android.resource://com.qd.clock/" + R.raw.video1;
Bitmap thumbAsBitmap = ThumbnailUtils.createVideoThumbnail(path,
MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
Bitmap image = this.getVideoThumbnailWithId(R.raw.video1);
mVideoView.setBackgroundResource(R.drawable.img_48);
return rootView;
}
示例12: processBitmap
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@Override
protected Bitmap processBitmap(Object data) {
String filePath= String.valueOf(data);
return ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);
}
示例13: processBitmap
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
@Override
protected Bitmap processBitmap(Object data) {
String filePath=String.valueOf(data);
return ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);
}
示例14: loadImageFromFilePath
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
public static Bitmap loadImageFromFilePath(String filePath) {
return ThumbnailUtils.createVideoThumbnail(filePath,
Thumbnails.MICRO_KIND);
}
示例15: getThumbnail
import android.provider.MediaStore.Video.Thumbnails; //导入依赖的package包/类
private Bitmap getThumbnail() {
if (filename == null) return null;
return ThumbnailUtils.createVideoThumbnail(filename, Thumbnails.FULL_SCREEN_KIND);
}