Capture Video as well as Images in iPhone - iphone

I am using ImagePickerController for Video Capturing. I need to save the capturing video as image also.
So I selected AVCaptureSession for capturing Images. I'm not able to run AVCaptureSession as well as ImagePickerController. So I need to give the ImagePickerController as input to the AVCaptureSession.
But I don't know how to do that. Please Help me.. and suggest me for the right way.

I found only these two. Hope its helps.
http://www.iphonedevsdk.com/forum/iphone-sdk-development/24025-uiimagepickercontroller-videorecording-iphone-3gs.html
UIImagePickerController: Getting image capture from video

I was having same issue.. I did work on image and video and used below code for image capturing:
- (void) snapImage: (id) sendern
{
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.delegate = self;
ipc.allowsImageEditing = YES;
[self presentModalViewController:ipc animated:YES];
}
And for video recording i used below code:
- (void) recordVideo: (id) sender
{
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
ipc.delegate = self;
ipc.allowsEditing = YES;
ipc.videoQuality = UIImagePickerControllerQualityTypeMedium;
ipc.videoMaximumDuration = 30.0f; // 30 seconds
ipc.mediaTypes = [NSArray arrayWithObject:#"public.movie"];
// ipc.mediaTypes = [NSArray arrayWithObjects:#"public.movie", #"public.image", nil];
[self presentModalViewController:ipc animated:YES];
}
Hope will help you both code snippets.

- (IBAction) useCamera: (id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker
animated:YES];
newMedia = YES;
}
}
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self.popoverController dismissPopoverAnimated:true];
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:YES];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
if (newMedia)
UIImageWriteToSavedPhotosAlbum(image, self,
#selector(image:finishedSavingWithError:contextInfo:),nil);
}
}
-(void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
if (error)
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: #"Save failed"
message: #"Failed to save image"
delegate: self
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}
}

The Apple docs and sample code related to AVFoundation has several mistakes. See iOS 4: Take photos with live preview using AVFoundation for code that actually captures images from a live preview.

Related

UIPopoverController How to fix for iPad?

I am getting an error / crash on iPad only when using the following code, iPhone works fine.
It is basically when trying to load the gallery to pick an image.
The debug error is;
"On iPad, UIImagePickerController must be presented via UIPopoverController'"
-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing photo library"
message:#"Device does not support a photo library"
delegate:nil
cancelButtonTitle:#"Abort!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
if (buttonIndex == 1) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType =UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing Camera"
message:#"Device does not support a Camera"
delegate:nil
cancelButtonTitle:#"Abort!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(#"the info opf picker is %#",info);
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
NSData *imageData;
if ([info objectForKey:UIImagePickerControllerEditedImage]) {
UIImage *image2=[info objectForKey:UIImagePickerControllerEditedImage];
//UIImage *myscaledImage=[self scaleImage:image2 toSize:CGSizeMake(18, 24)];
//imageData = UIImagePNGRepresentation(myscaledImage);
imageData=UIImageJPEGRepresentation(image2, .4);
NSLog(#"the lenght of the edited image data is %d",[imageData length]);
}
else {
UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
//UIImage *myscaledImage=[self scaleImage:image toSize:CGSizeMake(18, 24)];
//imageData = UIImagePNGRepresentation(myscaledImage);
imageData=UIImageJPEGRepresentation(image, .6);
NSLog(#"the lenght of the image dataa is %d",[imageData length]);
}
NSDictionary *tempDict=[NSDictionary dictionaryWithObjectsAndKeys:imageData,#"Image",#"Theme",#"Cell_Text",nil];
// NSLog(#"the custom array%# and the row =%d", customArray,currentCameraRow);
[customArray replaceObjectAtIndex:currentCameraRow withObject:tempDict];
[pool drain];
//NSLog(#"")
[self startThread];
[picker dismissModalViewControllerAnimated:YES];
[myCustomTableView reloadData];
NSLog(#"size of myObject: %zd", malloc_size(myCustomTableView));
}
Could anyone be so kind as to help with the code above ? I am guessing an if/else statement but have not the first idea of what it would be and where to place it.
Thanks in advance,
Chris
EDIT - Ok I now have it working the load from gallery now loads 'Photos' in a small window, where I can select, however there is no 'Select' or 'Choose' button, if I click the photo, there is no tick, to say it is selected, however it does select it, but to dismiss I click outside the window... So it works, but I am guessing I have missed something out, here is the code;
-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if(popoverController != nil)
{
[popoverController release];
popoverController = nil;
}
UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:picker];
popoverController = popover;
popoverController.delegate = self;
[popover presentPopoverFromRect:CGRectMake(0, 0, 200, 800)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
else
{
[self presentModalViewController:picker animated:YES];
}
// [self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing photo library"
message:#"Device does not support a photo library"
delegate:nil
cancelButtonTitle:#"Abort!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
if (buttonIndex == 1) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType =UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing Camera"
message:#"Device does not support a Camera"
delegate:nil
cancelButtonTitle:#"Abort!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(#"the info opf picker is %#",info);
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
NSData *imageData;
if ([info objectForKey:UIImagePickerControllerEditedImage]) {
UIImage *image2=[info objectForKey:UIImagePickerControllerEditedImage];
//UIImage *myscaledImage=[self scaleImage:image2 toSize:CGSizeMake(18, 24)];
//imageData = UIImagePNGRepresentation(myscaledImage);
imageData=UIImageJPEGRepresentation(image2, .4);
NSLog(#"the lenght of the edited image data is %d",[imageData length]);
}
else {
UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
//UIImage *myscaledImage=[self scaleImage:image toSize:CGSizeMake(18, 24)];
//imageData = UIImagePNGRepresentation(myscaledImage);
imageData=UIImageJPEGRepresentation(image, .6);
NSLog(#"the lenght of the image dataa is %d",[imageData length]);
}
NSDictionary *tempDict=[NSDictionary dictionaryWithObjectsAndKeys:imageData,#"Image",#"Theme",#"Cell_Text",nil];
// NSLog(#"the custom array%# and the row =%d", customArray,currentCameraRow);
[customArray replaceObjectAtIndex:currentCameraRow withObject:tempDict];
[pool drain];
//NSLog(#"")
[self startThread];
[picker dismissModalViewControllerAnimated:YES];
[myCustomTableView reloadData];
NSLog(#"size of myObject: %zd", malloc_size(myCustomTableView));
}
-(UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
}
The error is very clear:
On iPad, UIImagePickerController must be presented via UIPopoverController'
You need to put the image picker in a popover controller when run on the iPad. This is true when the sourceType is for the photo library. The camera based image picker can be shown as a full screen modal view controller.
This isn't an issue on the iPhone because the iPhone doesn't support the UIPopoverController.
The sample app PrintPhoto demonstrates how to show the image picker in a popover. Specifically, see PrintPhotoViewController.m.
Do something like this:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//present as a pop over vc
} else {
//present as a modal vc
}
To present a popover you might use this method
- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated
You can read the documentation at this link link

how to capture video

How can i record video
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = YES;
imagePickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
i tried this one but i am getting image capture and i am not getting video capture.
#import <MobileCoreServices/UTCoreTypes.h>
-(void)actionStartVideoRecord:(id)sender {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
return;
}
UIImagePickerController* imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.videoQuality = UIImagePickerControllerQualityTypeHigh;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mType = [info valueForKey:UIImagePickerControllerMediaType];
if([mType isEqualToString:#"public.movie"]){
[NSData dataWithContentsOfURL:[info objectForKey:#"UIImagePickerControllerMediaURL"]]
}
}
Once the imagePickerController is presented, start the videoCapture of the device.
For more info, see doc for UIImagePickerController
You can make a subclass of UIImagePickerController. There you can have a UIButton. On tapping that, you could start capturing the video.

iPhone camera not showing up

I am having awkward problem in using the ios camera from a action sheet: When the user touches the "picture button" an action sheet shows up with two options (to use a photo from the photo library or to take a picture with the camera).
Whatever option I choose, nothing happens, but when I select the media type again, it works.
Bellow is my code:
- (IBAction)selectMediaType: (id)sender {
[appDelegate hideTabBar];
UIActionSheet *action = [[UIActionSheet alloc]
initWithTitle: nil
delegate:self
cancelButtonTitle:#"Fechar"
destructiveButtonTitle: nil
otherButtonTitles:#"Galeria", #"Tirar Foto", nil];
[action showFromTabBar: appDelegate.tabController.tabBar];
}
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
NSArray *mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.delegate = self;
imagePicker.hidesBottomBarWhenPushed = YES;
imagePicker.mediaTypes = mediaTypes;
imagePicker.allowsEditing = NO;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePicker animated:YES];
imagePicker.hidesBottomBarWhenPushed = YES;
} else if (buttonIndex == 1) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
NSArray *mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.delegate = self;
imagePicker.mediaTypes = mediaTypes;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[self presentModalViewController:imagePicker animated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#""
message:#"Your device does not support this feature!"
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
}
} else {
[appDelegate showTabBar];
}
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image;
NSURL *mediaURL;
mediaURL = (NSURL *) [info valueForKey:UIImagePickerControllerMediaURL];
if (mediaURL == nil) {
image = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
}
imageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
[appDelegate showTabBar];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
[appDelegate showTabBar];
}
Could anyone help me with this?
Thanks.
I got it.
Basically it was a memory leak issue: I was switching views adding subviews in the super view (not in the current view) but I was not removing the old one from the super view, so I got a memory leak ;)

UIImagePickerControllerDelegate not responding properly

I'm using the UIImagePickerController in iOS 4.2.1 on an iPhone 3Gs. I've previously used the deprecated method
- (void)imagePickerController: didFinishPickingImage: editingInfo:
without a problem. I have another app using the new didFinishPickingMediaWithInfo API in another app, and the method is never getting called by the picker once media is chosen.
//MyViewController.h
#interface MyViewController : UIViewController < UIImagePickerControllerDelegate, UINavigationControllerDelegate>
//MyViewController.m
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController new] autorelease];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
picker.allowsEditing = NO;
[self presentModalViewController:picker animated:TRUE];
}
- (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo{
//**NEVER CALLED**
}
you have
- (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo
where you probably want
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
You have this:
- (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo
Look like you repeated the 'imagePickerController:' part of that method.
Putting the picker in the autorelease pool may be your problem -- it probably doesn't stick around long enough to call its delegate. Retain it instead:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
And then in the delegate you can release it:
[picker dismissModalViewControllerAnimated:YES];
[picker release];
It may be that this line:
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
is returning false. This happens if the user's photo library is empty; this would be true on the iPhone simulator, for example.
EDIT: As the other examples show, you've also mistyped the delegate method. It should be:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
This is program that i have used to upload video to webservice through iOS 4.2 on 3g
-(void)uploadeVideoClicked{
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
ipc.allowsEditing=NO;
ipc.videoQuality = UIImagePickerControllerQualityTypeMedium;
ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType];
ipc.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
ipc.delegate = self;
[self presentModalViewController:ipc animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSMutableDictionary *infoDict = [[NSMutableDictionary alloc]init];
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:#"public.image"]){
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:#"" message:#"You Select a image Please select Movie" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[myAlertView show];
[myAlertView release];
} else if ([mediaType isEqualToString:#"public.movie"]){
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
mAppDelegate.uploadType = #"Video";
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
[infoDict setValue:webData forKey:#"VideoUrl"];
[infoDict setValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:#"user_id"] forKey:#"user_id"];
//Call webService to upload video ;
}
[picker dismissModalViewControllerAnimated:YES];
[infoDict release];
}

how to show video or movie file into UIImagePickerController?

I am using UIImagePickerController that gives user to be able select an existing photo or use the camera to take an image at that time. And i can show that image in my application with UIImageView.
Now i want to use this ability for movies also. But i couldn't find any way to show the selected movie as an image in my app, just like the Photos app. as you know you can see photos and movies in the same list.
-(IBAction) selectImageSelected : (id)sender
{
actionSheet = [[UIActionSheet alloc] initWithTitle:#"Select Image"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Take Picture", #"Select from gallery", nil];
[actionSheet showInView:self.parentViewController.tabBarController.view];
}
- (void)actionSheet:(UIActionSheet *)_actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==0)
{
if( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] )
{
[AlertHandler showAlertMessage:[ErrorMessages getCameraNotFoundMsg] withTitle:#"No Camera Detected"];
return;
}
else
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];
}
}
else if(buttonIndex==1)
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
[self presentModalViewController:imagePicker animated:YES];
}
else
{
[actionSheet dismissWithClickedButtonIndex:2 animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:#"public.image"]){
// UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
NSLog(#"found an image");
// [UIImageJPEGRepresentation(image, 1.0f) writeToFile:[self findUniqueSavePath] atomically:YES];
// SETIMAGE(image);
CFShow([[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingString:#"/Documents"]]);
}
else if ([mediaType isEqualToString:#"public.movie"]){
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(#"found a video");
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
//NSData *video = [[NSString alloc] initWithContentsOfURL:videoURL];
// [webData writeToFile:[self findUniqueMoviePath] atomically:YES];
CFShow([[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingString:#"/Documents"]]);
CGSize sixzevid=CGSizeMake(imagePicker.view.bounds.size.width,imagePicker.view.bounds.size.height-100);
UIGraphicsBeginImageContext(sixzevid);
[imagePicker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
eventButton.imageView.image=viewImage;
// NSLog(videoURL);
}
[picker dismissModalViewControllerAnimated:YES];
}
/*
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo1
{
[imagePicker dismissModalViewControllerAnimated:YES];
imagePicker.view.hidden = YES;
eventButton.imageView.image = image;
imageSelected = YES;
}
*/
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[imagePicker dismissModalViewControllerAnimated:YES];
imageSelected = NO;
}
The -thumbnailImageAtTime:timeOption: method of MPMoviePlayerController looks like it might help you get an image to display.
To have the picker view with only movie files
replace
imagePicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
with
picker.mediaTypes = [NSArray arrayWithObject:#"public.movie"];