public void SetUpRecoder() { try { if (null == activity) { return; } if (userResponse == UserResponse.Video) { mediaRecorder = new MediaRecorder(); mediaRecorder.Reset(); mediaRecorder.SetAudioSource(AudioSource.Mic); mediaRecorder.SetVideoSource(VideoSource.Surface); mediaRecorder.SetOutputFormat(OutputFormat.Mpeg4); mediaRecorder.SetOutputFile(path + "/test.mp4"); mediaRecorder.SetVideoEncodingBitRate(10000000); mediaRecorder.SetVideoFrameRate(30); mediaRecorder.SetVideoSize(videoSize.Width, videoSize.Height); mediaRecorder.SetVideoEncoder(VideoEncoder.H264); mediaRecorder.SetAudioEncoder(AudioEncoder.Aac); //int rotation = (int)activity.WindowManager.DefaultDisplay.Rotation; //int orientation = ORIENTATIONS.Get(rotation); if (LensFacing == CameraFacing.BACK) { mediaRecorder.SetOrientationHint(90); } else { mediaRecorder.SetOrientationHint(270); } mediaRecorder.SetMaxDuration(30000); mediaRecorder.Prepare(); } else { mediaRecorder = new MediaRecorder(); mediaRecorder.Reset(); mediaRecorder.SetAudioSource(AudioSource.Mic); mediaRecorder.SetOutputFormat(OutputFormat.ThreeGpp); mediaRecorder.SetAudioEncoder(AudioEncoder.AmrNb); mediaRecorder.SetOutputFile(path + "/test.mp3"); mediaRecorder.SetMaxDuration(30000); mediaRecorder.Prepare(); } } catch (System.Exception ex) { } }