2010年12月7日星期二

Android VideoCamera Analysis

I wanted to know how to use camera recording. So I checked the file "VideoCamera" in android source code. The following was what it did.


1. If you want to start recording, you need Camera and MediaRecorder.
2. Decide when to open a camera device, how to set parameters of the camera and set the previewDisplay always before starting previewing.
3. Decide when to close a camera device.
4. Stop the camera and media recording in onPause() and resume them in onResume().
5. in callback method surfaceCreated, mSurfaceHolder is set.
6. in callback method surfaceDestroy, mSurfaceHolder is destroyed.
7. in callback method surfaceChanged, mSurfaceHolder is set again. But if the state of the Activity is Pausing, do nothing just return. Restart previewing and recording.


The following is an example.

没有评论: