views:

945

answers:

2

Hi,

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  A: 

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"]){...}
}
lostInTransit
Strange it doesn't work for me. I've tried your code but avaliableMediaTypesForSource:UIImagePickerControllerSourceTypePhotoLibrary only returns one object in the array and that is @"public.image"I've tried on two different iPhones 3G. Will install the new OS 3.1.2 later to see whether that makes a difference.
Ben
hmm that is strange. Were you able to save videos to your photo roll?
lostInTransit
A: 

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 ?

Deepak