这节课会介绍如何使用现有的Camera程序来录制一个视频。和拍照一样,我们没有必要去重新发明录像程序。大多数的Android程序都有自带Camera来进行录像。[这一课的内容大多数与前面一课类似,简要带过,一些细节不赘述了]。
<manifest ... > <uses-feature android:name="android.hardware.camera" /> ... </manifest ... >与上一课的拍照一样,你可以在启动Camera之前,使用
hasSystemFeature(PackageManager.FEATURE_CAMERA)
.来检查是否存在Camera。
private void dispatchTakeVideoIntent() { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO); }
public static boolean isIntentAvailable(Context context, String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
VideoView
.
private void handleCameraVideo(Intent intent) { mVideoUri = intent.getData(); mVideoView.setVideoURI(mVideoUri); }
学习自:http://developer.android.com/training/camera/videobasics.html,欢迎一起交流!
转载请注明出自:http://blog.csdn.net/kesenhoo,谢谢!