Code example for MediaRecorder: Recording audio and video

Methods: preparesetCamerasetOnErrorListenersetOnInfoListenersetOutputFilestart

0
			Logger.v("recorder released"); 
		} 
 
		isRecording = false;
 
		recorder = new MediaRecorder();
		if(camera != null)
			recorder.setCamera(camera);
		recorder.setOnErrorListener(this);
		recorder.setOnInfoListener(this);
		 
		initRecorderMore(); 
	} 
 
	/** 
	 * <p> 
	 * initialize more (this is the point for setting more parameters) 
	 * <br> 
	 * <br> 
	 * <b>caution</b>: it is called after MediaRecorder object's creation, and called before MediaRecorder.prepare(). 
	 * </p> 
	 */ 
	protected abstract void initRecorderMore(); 
 
	/** 
	 *  
	 * @return 
	 */ 
	synchronized public boolean isRecording() 
	{ 
		return isRecording;
	} 
 
	/** 
	 * start recording 
	 *  
	 * @param filepath 
	 * @param camera null if none (should be unlocked before handing) 
	 */ 
	synchronized public void startRecording(String filepath, Camera camera)
	{ 
		this.camera = camera; 
 
		initRecorder(); 
		try 
		{ 
			this.filepath = filepath; 
			recorder.setOutputFile(filepath); 
 
			recorder.prepare(); 
			recorder.start(); 
 
			isRecording = true; 
			 
			Logger.v("recording started");