Code example for MediaRecorder: Recording audio and video

Methods: preparesetOutputFilesetOutputFormatsetPreviewDisplaysetVideoEncodersetVideoFrameRatesetVideoSizesetVideoSourcestart

0
		public void surfaceDestroyed(SurfaceHolder holder) {
			// 
		} 
 
		public void initializeVideoSettings() { 
			myRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 
			myRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
			myRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); 
 
			myRecorder.setOutputFile("/sdcard/sample.3gp"); 
			myRecorder.setVideoFrameRate(30); 
			myRecorder.setVideoSize(320, 240);		
				myRecorder.setPreviewDisplay(v_holder.getSurface()); 
			try { 
				myRecorder.prepare(); //
			} catch (Exception e) {
				Log.e("recMovie", e.getMessage());
			} 
		} 
 
		@Override 
		public boolean onTouchEvent(MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_DOWN) {
				if (!isRecording) {
					initializeVideoSettings();  
					myRecorder.start(); 
					isRecording = true; 
 
				} else { 
					myRecorder.stop(); 
					myRecorder.reset();