0
    } 
 
    private void initRecorder() { 
        //CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); 
        //mediaRecorder.setProfile(cpHigh); 
        mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
        mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
        mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
        mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
        mediaRecorder.setVideoEncodingBitRate(1500000);
        mediaRecorder.setAudioEncodingBitRate(8000);
        mediaRecorder.setAudioSamplingRate(8000);
        mediaRecorder.setAudioChannels(1);
        mediaRecorder.setVideoFrameRate(20);
        mediaRecorder.setVideoSize(640, 480);
        mediaRecorder.setMaxFileSize(10000000);
        mediaRecorder.setMaxDuration(100000);
        mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
        mediaRecorder.setOutputFile("/sdcard/recorded_video.mp4");
    } 
 
    private void getViews() { 
        captureVideoButton = (Button) findViewById(R.id.captureVideoButton);
        playVideoButton = (Button) findViewById(R.id.playVideoButton);
        saveVideoButton = (Button) findViewById(R.id.saveVideoButton);
        titleEditText = (EditText) findViewById(R.id.titleEditText);
        surfaceView = (SurfaceView) this.findViewById(R.id.videoSurfaceView);
        recorderButton = (Button) findViewById(R.id.recorderVideoButton);
    } 
 
    private void setLister() { 
        captureVideoButton.setOnClickListener(this);
        playVideoButton.setOnClickListener(this);
        saveVideoButton.setOnClickListener(this);
        recorderButton.setOnClickListener(this);
        surfaceView.setClickable(true);
        surfaceView.setOnClickListener(this);
    } 
 
    private void prepareRecorder() { 
        mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
        try { 
            mediaRecorder.prepare();
        } catch (IOException e) {
            e.printStackTrace();
            finish();
        } 
    } 
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present. 
        getMenuInflater().inflate(R.menu.video_recoder, menu);
        return true; 
    } 
 
    @Override 
    public void onClick(View v) {
        if (v == captureVideoButton) {
            Intent captureVideoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
            startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);
        } else if (v == playVideoButton) {
            Intent playVideoIntent = new Intent(Intent.ACTION_VIEW, videoFileUri);
            startActivity(playVideoIntent);
        } else if (v == saveVideoButton) {
            values.put(MediaStore.MediaColumns.TITLE, titleEditText.getText().toString());
            int numRecordsUpdated = getContentResolver().update(videoFileUri, values, null, null);
            if (numRecordsUpdated == 1) {
                Toast.makeText(this, "Updated " + titleEditText.getText().toString(), Toast.LENGTH_SHORT).show();
            } else { 
                Toast.makeText(this, "Error " + titleEditText.getText().toString(), Toast.LENGTH_SHORT).show();
            } 
        } else if (v == recorderButton) {
            if (recording) {
                mediaRecorder.stop();
                recording = false;
                initRecorder(); 
                prepareRecorder(); 
            } else { 
                recording = true;