UIImagePicker is the simple way to record video. It is a portrait only camera (although the image obviously turns when the device is turned, the button bar is portrait only)
Add these delegates in the .h file
@interface MyViewController_iPhone : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate> //-ADD THESE
{
Then in your .m file
//*****************************************
//*****************************************
//********** RECORD VIDEO BUTTON **********
//*****************************************
//*****************************************
- (IBAction)RecordVideoButton:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *videoRecorder = [[UIImagePickerController alloc] init];
videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
videoRecorder.delegate = self;
NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
NSArray *videoMediaTypesOnly = [mediaTypes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];
if ([videoMediaTypesOnly count] == 0) //Is movie output possible?
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Sorry but your device does not support video recording"
delegate:nil
cancelButtonTitle:@"OK"
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet showInView:[[self view] window]];
[actionSheet autorelease];
}
else
{
//Select front facing camera if possible
if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront])
videoRecorder.cameraDevice = UIImagePickerControllerCameraDeviceFront;
videoRecorder.mediaTypes = videoMediaTypesOnly;
videoRecorder.videoQuality = UIImagePickerControllerQualityTypeMedium;
videoRecorder.videoMaximumDuration = 180; //Specify in seconds (600 is default)
[self presentModalViewController:videoRecorder animated:YES];
}
[videoRecorder release];
}
else
{
//No camera is availble
}
}
//***************************************
//***************************************
//********** RECORD VIDEO DONE **********
//***************************************
//***************************************
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissModalViewControllerAnimated:YES];
//Save the movie
NSLog(@"Video recorded: %@", info);
}
//*****************************************
//*****************************************
//********** RECORD VIDEO CANCEL **********
//*****************************************
//*****************************************
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
}