Picking video from PhotoLibrary with UIImagePickerController in OS 3.1

10.5k views Asked by At

I am trying to pick a video from the photo library. In principle I know how to do it you set the mediaType of the image picker to an NSArray with kUTTypeMovie as its only object. But this doesn't seem to work on an iPhone 3G. Since OS 3.1 you can store videos you've received in your photo library. When you start the build in 'Photos' application the videos appear. However this doesn't work using the UIImagePickerController. The controller reports that it only supports images. When you try to set the mediaType of the controller with kUTTypeMovie it actually crashes.

If you don't specify the media type only images are shown in the picker.

As anyone managed to pick a video from the photo library? If yes did it only work on the 3gs or on the 3G as well?

Regards

Ben

2

There are 2 answers

1
Deepak On

Hey, I am also unable to get movie objects on 3G using the above mentioned code. It crashes on my 3G. It however works on my 3GS, but the issue is it shows a mix of both images and movies in photo library. I tried the following code:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

and on my 3GS running OS 3.1.2, it shows me videos cum images stored in my photo library.

Whereas if I try doing the following:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.movie"];
[videoPickerCtrl setMediaTypes:mediaTypesAllowed];

Then all it shows me is videos stored in Camera Roll, and nothing else. Can somebody help ?

3
lostInTransit On

I got the imagepicker working on a 3g and a 3gs to pick videos.

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imgPicker setMediaTypes:mediaTypesAllowed];

And to get the picked video

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:@"public.movie"]){...}
}