本文整理汇总了Java中android.media.ThumbnailUtils.createVideoThumbnail方法的典型用法代码示例。如果您正苦于以下问题:Java ThumbnailUtils.createVideoThumbnail方法的具体用法?Java ThumbnailUtils.createVideoThumbnail怎么用?Java ThumbnailUtils.createVideoThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.ThumbnailUtils
的用法示例。
在下文中一共展示了ThumbnailUtils.createVideoThumbnail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import android.media.ThumbnailUtils; //导入方法依赖的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: extractThumbnail
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
public static boolean extractThumbnail(String videoPath, String thumbPath) {
if (!isFileExist(thumbPath)) {
Bitmap thumbnail = null;
thumbnail = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
if (thumbnail == null) {
try {
thumbnail = createVideoThumbnail(videoPath);
} catch (Exception e) {
e.printStackTrace();
}
}
if (thumbnail != null) {
saveBitmap(thumbnail, thumbPath, true);
return true;
}
}
return false;
}
示例3: onInfo
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN) {
MediaRecorder tempRecorder = recorder;
recorder = null;
if (tempRecorder != null) {
tempRecorder.stop();
tempRecorder.release();
}
final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
onVideoTakeCallback.onFinishVideoRecording(bitmap);
}
});
}
}
示例4: stopVideoRecording
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
public void stopVideoRecording(CameraSession session, boolean abandon) {
try {
CameraInfo info = session.cameraInfo;
Camera camera = info.camera;
if (camera != null && recorder != null) {
MediaRecorder tempRecorder = recorder;
recorder = null;
tempRecorder.stop();
tempRecorder.release();
camera.reconnect();
camera.startPreview();
session.stopVideoRecording();
}
if (!abandon) {
final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
onVideoTakeCallback.onFinishVideoRecording(bitmap);
}
});
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
示例5: onPostExecute
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
/**
* After completing background task
* Dismiss the progress dialog
**/
@Override protected void onPostExecute(String file_url) {
circularProgress.setVisibility(View.GONE);
Toast.makeText(mContext, "Post Saved", Toast.LENGTH_LONG).show();
String extension = "";
// recognizing weather its a image or video from file format
int i = file_url.lastIndexOf('.');
extension = file_url.substring(i + 1);
if (extension.equalsIgnoreCase("mp4")) {
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(file_url, MediaStore.Images.Thumbnails.MINI_KIND);
ivImage.setImageBitmap(thumbnail);
//ivPlayBtn.setVisibility(View.VISIBLE);
} else {
ivImage.setImageDrawable(Drawable.createFromPath(file_url));
}
((OnPostDownload) activity).refreshList();
}
示例6: getVideoThumbnailStream
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.FROYO)
private InputStream getVideoThumbnailStream(String filePath)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO)
{
Bitmap bitmap = ThumbnailUtils
.createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
if (bitmap != null)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
return new ByteArrayInputStream(bos.toByteArray());
}
}
return null;
}
示例7: getVideoThumbnail
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
/**
* 获取视频缩略图
*/
public static Bitmap getVideoThumbnail(String filePath, int width, int height, int kind) {
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath, kind);
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
return bitmap;
}
示例8: getVideoThumbnail
import android.media.ThumbnailUtils; //导入方法依赖的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;
}
示例9: showAlert
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
private void showAlert() {
// fadeOut(findViewById(R.id.shutter_button));
if (mCurrentVideoFilename != null) {
Bitmap src = ThumbnailUtils.createVideoThumbnail(
mCurrentVideoFilename, Video.Thumbnails.MINI_KIND);
// MetadataRetriever already rotates the thumbnail. We should rotate
// it back (and mirror if it is front-facing camera).
CameraInfo[] info = CameraHolder.instance().getCameraInfo();
if (info[mCameraId].facing == CameraInfo.CAMERA_FACING_BACK) {
src = Util.rotateAndMirror(src, -mOrientationHint, false);
} else {
src = Util.rotateAndMirror(src, -mOrientationHint, true);
}
mVideoFrame.setImageBitmap(src);
mVideoFrame.setVisibility(View.VISIBLE);
}
// int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play};
// for (int id : pickIds) {
// View button = findViewById(id);
// fadeIn(((View) button.getParent()));
// }
}
示例10: doInBackground
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
@Override
protected Object doInBackground(Object... params) {
if (mFileList.get(imageIndex).getName().endsWith(".mp4")){
bitmap = ThumbnailUtils.createVideoThumbnail(
mFileList.get(imageIndex).getAbsolutePath(),
MediaStore.Video.Thumbnails.FULL_SCREEN_KIND);
} else {
bitmap = BitmapFactory.decodeFile(mFileList.get(imageIndex).getAbsolutePath());
bitmap = Bitmap.createScaledBitmap(bitmap,
640, 360, false);
try{
ByteArrayOutputStream bytearroutstream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytearroutstream);
bytearroutstream.close();
} catch(IOException e){
Log.e("IOException", e.toString());
}
}
return "";
}
示例11: doInBackground
import android.media.ThumbnailUtils; //导入方法依赖的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;
}
}
示例12: onInfo
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN) {
MediaRecorder tempRecorder = recorder;
recorder = null;
if (tempRecorder != null) {
tempRecorder.stop();
tempRecorder.release();
}
if (onVideoTakeCallback != null) {
final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (onVideoTakeCallback != null) {
onVideoTakeCallback.onFinishVideoRecording(bitmap);
onVideoTakeCallback = null;
}
}
});
}
}
}
示例13: layoutShareVideo
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
protected void layoutShareVideo() {
findViewById(R.id.captionText).setVisibility(View.GONE);
Uri uri = (Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);
final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail(
FileUtils.getRealPathFromURI(this, uri),
MediaStore.Images.Thumbnails.MINI_KIND);
final MeasuredMediaView imageView = (MeasuredMediaView) findViewById(R.id.shareImagePreview);
imageView.setImageBitmap(thumbnail);
imageView.setMeasureListener(new MeasureListener() {
@Override
public void measure(int widthMeasureSpec, int heightMeasureSpec) {
imageView.setImageBitmap(ImageHelper.getRoundedCornerBitmap(
thumbnail, 8, true, widthMeasureSpec));
}
});
findViewById(R.id.captionTextAlt).requestFocus();
imageView.setVisibility(View.VISIBLE);
}
示例14: getStreamFromVideo
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
private InputStream getStreamFromVideo(ImageDownloadInfo imageDownloadInfo) throws IOException {
try {
if (imageDownloadInfo.getExtraInfo() < MediaStore.Images.Thumbnails.MINI_KIND || imageDownloadInfo.getExtraInfo() > MediaStore.Video.Thumbnails.MICRO_KIND) {
imageDownloadInfo.setExtraInfo(MediaStore.Images.Thumbnails.MINI_KIND);
}
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(imageDownloadInfo.getImageUrl(), imageDownloadInfo.getExtraInfo());
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, os);
return new ByteArrayInputStream(os.toByteArray());
} catch (Exception e) {
Log.e("error", "e: " + e.toString());
}
return null;
}
示例15: createVideoThumbnail
import android.media.ThumbnailUtils; //导入方法依赖的package包/类
private static Bitmap createVideoThumbnail(String vidioPath, int width,
int height, int kind) {
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(vidioPath, kind);
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
return bitmap;
}