Code example for MediaRecorder

Methods: setAudioEncodersetAudioSourcesetMaxDurationsetOutputFilesetOutputFormat

0
	private boolean isRecording = false;
	private Context mContext;
 
	//////// ********* Constructor ********* ////////// 
	public RecordingHelper(File mPath, Context _context) {
		mRecorder = new MediaRecorder();
		if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
			mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
			mRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
			mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			mRecorder.setOutputFile(mPath.toString());
			mRecorder.setMaxDuration(60000 * 60);
		} else { 
			Toast.makeText(mContext, "sdcard not available", Toast.LENGTH_LONG).show();
		} 
	} 
 
	/////// ********* Function to start recording ********* ///////// 
	public void startRecording() { 
		if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
Contextual code suggestions in your IDE  Get Codota for Java