I set up SurfaceView.
SurfaceView mySurfaceView = (SurfaceView) findViewById(R.id.surfaceView1); SurfaceHolder holder = mySurfaceView.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
And set up SurfaceHolder.Callback
public void surfaceCreated(SurfaceHolder holder) { } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { _holder = holder; } public void surfaceDestroyed(SurfaceHolder holder) { }Create MediaRecorder
_recorder = new MediaRecorder();Initialize MediaRecorder and start it.
_recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); _recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); _recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); _recorder.setOutputFile("/sdcard/sample.3gp"); _recorder.setPreviewDisplay(_holder.getSurface()); try { _recorder.prepare(); } catch (Exception e) { Log.e("test", "recorder error"); } _recorder.start();stop it.
_recorder.stop(); _recorder.reset();
source code here
Actually, I would like to try Camera class and Camera.lock() method. but it has exception. in my NexusOne.
0 件のコメント:
コメントを投稿