当前位置: 首页>>代码示例>>Java>>正文


Java ThumbnailUtils.createVideoThumbnail方法代码示例

本文整理汇总了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;
	}
}
 
开发者ID:learnNcode,项目名称:MediaChooser,代码行数:20,代码来源:GalleryCache.java

示例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;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:Utils.java

示例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);
            }
        });
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:CameraController.java

示例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);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:27,代码来源:CameraController.java

示例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();
}
 
开发者ID:rrishabhj,项目名称:InstaImageDownloader,代码行数:25,代码来源:DownloadFragment.java

示例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;
}
 
开发者ID:hongyangAndroid,项目名称:base-imageloader,代码行数:17,代码来源:ImageDecorder.java

示例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;
}
 
开发者ID:CaMnter,项目名称:AndroidLife,代码行数:10,代码来源:ImageUtil.java

示例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;
}
 
开发者ID:csulennon,项目名称:GreenDamFileExploere,代码行数:13,代码来源:CMImageLoader.java

示例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()));
//        }
    }
 
开发者ID:yinglovezhuzhu,项目名称:AndroidMedia,代码行数:23,代码来源:CamcorderActivity.java

示例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 "";

}
 
开发者ID:RBWare,项目名称:Glass-Photo-Gallery,代码行数:25,代码来源:GalleryActivity.java

示例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;
    }
}
 
开发者ID:learnNcode,项目名称:MediaChooser,代码行数:20,代码来源:GalleryCache.java

示例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;
                    }
                }
            });
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:24,代码来源:CameraController.java

示例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);
}
 
开发者ID:buddycloud,项目名称:buddycloud-android,代码行数:21,代码来源:ShareActivity.java

示例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;
}
 
开发者ID:redleaf2002,项目名称:magic_imageloader_network,代码行数:15,代码来源:BaseDownloadStream.java

示例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;
}
 
开发者ID:lo625090140,项目名称:lqrwechatrongcloud,代码行数:8,代码来源:VideoThumbLoader.java


注:本文中的android.media.ThumbnailUtils.createVideoThumbnail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。