Code example for MediaRecorder

Methods: setAudioSourcesetMaxDurationsetOutputFilesetProfilesetVideoSource

0
         WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
 
        String videoPath = "";
         
        recorder = new MediaRecorder();// Instantiate our media recording object
        initRecorder(videoPath);
        //setContentView(R.layout.view); 
 
        SurfaceView cameraView = null;// (SurfaceView) findViewById(R.id.surface_view);
        holder = cameraView.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 
        cameraView.setClickable(true);// make the surface view clickable
        cameraView.setOnClickListener((OnClickListener) this);// onClicklistener to be called when the surface view is clicked
    } 
 
 
    private void initRecorder (String path)
    { 
    	initRecorder(-1, path, CamcorderProfile.QUALITY_HIGH);
    } 
     
    private void initRecorder(int maxDuration, String outputFile, int camProfile) {
        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
        CamcorderProfile cpHigh = CamcorderProfile
                .get(camProfile);
        recorder.setProfile(cpHigh);
        recorder.setOutputFile(outputFile);
         
        if (maxDuration != -1)
        recorder.setMaxDuration(maxDuration);
    } 
 
    private void prepareRecorder() { 
        recorder.setPreviewDisplay(holder.getSurface());