私は iPhone アプリを持っています。魔女はビデオを録画できます。問題は向きです。常に縦向きです。デバイスの向きを検出し、ビデオを正しい向きで保存する必要があります。
// setup video recording
mRecordingDelegate = new RecordingDelegate();
// setup the input Video part
mCaptureVideoInput = new AVCaptureDeviceInput(AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video), out mVideoError);
//Audio part
mCaptureAudioInput = new AVCaptureDeviceInput(AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Audio), out mAudioError);
// setup the capture session
mCaptureSession = new AVCaptureSession();
mCaptureSession.SessionPreset = AVCaptureSession.PresetMedium;
mCaptureSession.AddInput(mCaptureVideoInput);
mCaptureSession.AddInput(mCaptureAudioInput);
// setup the output
mCaptureOutput = new AVCaptureMovieFileOutput();
mCaptureOutput.MaxRecordedDuration = MonoTouch.CoreMedia.CMTime.FromSeconds(VideoLength, 1);
//add Output to session
mCaptureSession.AddOutput(mCaptureOutput);
// add preview layer
mPrevLayer = new AVCaptureVideoPreviewLayer(mCaptureSession);
mPrevLayer.Frame = new RectangleF(0, 0, 320, 480);
mPrevLayer.BackgroundColor = UIColor.Clear.CGColor;
mPrevLayer.VideoGravity = "AVLayerVideoGravityResize";
// Show video output
mCaptureSession.CommitConfiguration();
mCaptureSession.StartRunning();
RecordingDelegate.Stopped += delegate {
if(recording)
OnBtnStopRecordingVideo();
};
// add subviews
this.InvokeOnMainThread (delegate
{
this.View.Layer.AddSublayer (mPrevLayer);
});