views:

565

answers:

3

Hi,

I am facing a problem where-in I cannot select videos from the photo album in iPhone 2G/3G device. The default photos application does show videos and is capable of playing them, which in turn means that UIImagePickerController should clearly be capable of showing videos in photo album and selecting them.

I have coded this to determine whether the device is capable of snapping a photo, recording video, selecting photos and selecting videos:

 // Check if camera and video recording are available:
 [self setCameraAvailable:NO];
 [self setVideoRecordingAvailable:NO];
 [self setPhotoSelectionAvailable:NO];
 [self setVideoSelectionAvailable:NO];

 // For live mode:
 NSArray *availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
 NSLog(@"Available types for source as camera = %@", availableTypes);
 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
 {
  if ([availableTypes containsObject:(NSString*)kUTTypeMovie])
   [self setVideoRecordingAvailable:YES];
  if ([availableTypes containsObject:(NSString*)kUTTypeImage])
   [self setCameraAvailable:YES];
 }

 // For photo library mode:
 availableTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
 NSLog(@"Available types for source as photo library = %@", availableTypes);
 if ([availableTypes containsObject:(NSString*)kUTTypeImage])
  [self setPhotoSelectionAvailable:YES];
 if ([availableTypes containsObject:(NSString*)kUTTypeMovie])
  [self setVideoSelectionAvailable:YES];

The resulting logs for 3G device is as follows:

2010-05-03 19:09:09.623 xyz [348:207] Available types for source as camera = (
    "public.image"
)
2010-05-03 19:09:09.643 xyz [348:207] Available types for source as photo library = (
    "public.image"
)

As the logs state, for photo library the string equivalent of kUTTypeMovie is not available and hence the UIImagePickerController does not show up (or rather throws exception if we set the source types array which includes kUTTypeMovie) the movie files in photo library.

I havent tested for 3GS, but I am sure that this problem does not exist in it with reference to other threads.

I have built the app for both 3.0 (base SDK) and 3.1 but with the same results.

This issue is already discussed in the thread: http://www.iphonedevsdk.com/forum/iphone-sdk-development/36197-uiimagepickercontroller-does-not-show-movies-albums.html

But it does not seem to host a solution.

Any solutions to this problem?

Thanks and Regards, Raj Pawan

A: 

ON 3GS its working perfectly fine, and the thing is 3Gs has rolled after SDK 3.1 so 3.0 don't have any handling of the video related things..!

Arpan
Yeah, the same observations I have already made. But 3.1 does not seem to have this fix either. Check my question above. I have already built for both 3.0 and 3.1 SDK for iPhone 3G, neither of them display videos in UIImagePickerController.
Raj
+2  A: 

The default photos application does show videos and is capable of playing them

But how have you tested this? 2G/3G can't record video. So you can't place video files to an image picker. Or am I wrong?

Documentation explicitly tells: "Because a media source may not be present or may be unavailable, devices may not always support all source types." So iPhone OS assumes that there can't be any movies and does not allow to select them. I think so.

Alexander Babaev
Raj
Yes, but SDK says: "Before calling this function, you should call the UIVideoAtPathIsCompatibleWithSavedPhotosAlbum function to determine if it is possible to save videos to the Saved Photos album." So you can do it but only if device supports it. I know about diferent cameras, but don't think that it is an appropriate API usage.
Alexander Babaev
Ammmm, I didnt check out UIVideoAtPathIsCompatibleWithSavedPhotosAlbum earlier, but videos can be saved to camera roll using UISaveVideoAtPathToSavedPhotosAlbum directly. Its a valid argument then, ideally 2G / 3G devices are not capable of selecting videos because THEY CANT PLAY THEM? However, once the videos are placed in camera roll, the default photos application is capable of selecting the videos and playing it.
Raj
+2  A: 

As the videos are always compressed after being picked (the raw video recorder files are very big), and the 2G/3G models not being able to hardware encode/decode h.264, they left it out of the UIImagePickerController API. That is unfortunate as we all would love to pick videos on those devices as well.

nobre