Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone video recording: "cameraCaptureMode 1 not available because mediaTypes does contain public.movie"

I tried to record a video. The message I got is from the following code on the device:

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = YES;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];

Any ideas? I think it should be really easy to take a video. When I start the "Camera" app of the phone I have the choice between video and picture. Shouldn't it be available for my app also?

like image 775
Danail Avatar asked Sep 11 '10 12:09

Danail


3 Answers

The problem was the way I was trying to set the mode to video mode.

Instead of using this:

imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;

I changed it to this:

imagePickerController.mediaTypes =  
        [NSArray arrayWithObject:(NSString *)kUTTypeMovie];

and it worked.

like image 173
Danail Avatar answered Nov 08 '22 18:11

Danail


For Swift 3.0, you have to add below line to support both photo and video

import MobileCoreServices

  imagePicker.mediaTypes = [kUTTypeMovie as String, kUTTypeImage as String]
like image 11
Hiren Panchal Avatar answered Nov 08 '22 18:11

Hiren Panchal


Add to above answers, as Micko mentioned, you need to add MobileCoreServices.framework in your project and ref it in your imagePickerController. For those who want to have a switch under the toolbar in your image shooting view, just set the mediaTypes delegate as follows:

imagePC.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, (NSString *)kUTTypeImage, nil];

Now, you can have both still image taking and video taking, enjoy!!!

like image 7
Jaylee Avatar answered Nov 08 '22 16:11

Jaylee