//存储路径uri的获得
1 Intent intent = getIntent();
2 Bundle myExtras = intent.getExtras();
3
4 long requestedSizeLimit = 0;
5 if (mIsVideoCaptureIntent && myExtras != null) {
6 Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
7 Log.e(TAG, saveUri.toString());
8 if (saveUri != null) {
9 try {
10 mCameraVideoFileDescriptor = mContentResolver
11 .openFileDescriptor(saveUri, "rw")
12 .getFileDescriptor();
13
14 Log.e(TAG, mCameraVideoFileDescriptor.toString());
15 mCurrentVideoUri = saveUri;
16 } catch (java.io.FileNotFoundException ex) {
17 // invalid uri
18 Log.e(TAG, ex.toString());
19 }
20 }
21 requestedSizeLimit = myExtras.getLong(MediaStore.EXTRA_SIZE_LIMIT);
22 }
23 mMediaRecorder = new MediaRecorder();
24
25 mMediaRecorder.setCamera(mCameraDevice);
26 mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
27 mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
28 mMediaRecorder.setProfile(mProfile);
29 mMediaRecorder.setMaxDuration(mMaxVideoDurationInMs);
30
31 // Set output file.
32 if (mStorageStatus != STORAGE_STATUS_OK) {
33 Log.e(TAG, "1");
34 mMediaRecorder.setOutputFile("/dev/null");
35 } else {
36 // Try Uri in the intent first. If it doesn't exist, use our own
37 // instead.
38 Log.e(TAG, "2");
39 if (mCameraVideoFileDescriptor != null) {
40 Log.e(TAG, "3");
41 mMediaRecorder.setOutputFile(mCameraVideoFileDescriptor);
42 } else {
43 createVideoPath();
44 Log.e(TAG, "4");
45 mMediaRecorder.setOutputFile(mCameraVideoFilename);
46 }
47 }
android系统相机源码下载地址:https://files.cnblogs.com/qinghuaideren/Camera.rar