Code example for MediaRecorder: Recording audio and video

Methods: preparesetAudioEncodersetAudioSourcesetOutputFilesetOutputFormatstart

0
	} 
	 
	protected void startRecording(String file){
		if (!isRecording){
			saveFile=file;
			recorder = new MediaRecorder();
			recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
			recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
			recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			recorder.setOutputFile(this.recording);
			try { 
				recorder.prepare();
			} catch (IllegalStateException e) {
				// TODO Auto-generated catch block 
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block 
				e.printStackTrace();
			} 
			isRecording = true;
			recorder.start();
		} 
	} 
	 
	private void moveFile(String file) {
		/* this is a hack to save the file as the specified name */