Code example for MediaRecorder

Methods: setAudioSourcesetMaxDurationsetMaxFileSizesetOutputFilesetProfilesetVideoSource

0
		getMenuInflater().inflate(R.menu.main, menu);
		return true; 
	} 
 
    private void initRecorder() { 
        recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 
        CamcorderProfile cpHigh = CamcorderProfile
                .get(CamcorderProfile.QUALITY_HIGH);
        recorder.setProfile(cpHigh);
        String filePath = Environment.getExternalStorageDirectory().getPath() + "/videocapture_example.mp4";
        Log.d(TAG, "filePath: " + filePath);
        recorder.setOutputFile(filePath);
        recorder.setMaxDuration(50000); // 50 seconds
        recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
    } 
 
    private void prepareRecorder() { 
        recorder.setPreviewDisplay(holder.getSurface());
 
Contextual code suggestions in your IDE  Get Codota for Java