Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

objective c - How do I pick and record video using UIImagePickerController for iPhone?

I want to pick a video from iPhone for my application for uploading on the Web. I am using the UIImagePickerController for it.

For for opening picker

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentModalViewController:imagePicker animated:YES];

It opens the photo library and only shows the movie type content.
Now I have the following questions:

  • How do I get the video when I select the video then it ready to play and then when I click on choose then its compression nothing happen .. even I am not able to cancel it.
  • As we have separate folders in iphone then how do we open video folder?

If I am able to choose then how do I get video detail as delegate method is

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {

and it has (UIImage *)img parameter. How do I get it as video?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're using the wrong delegate method. iOS 3.0 introduced imagePickerController:didFinishPickingMediaWithInfo: to replace imagePickerController:didFinishPickingImage:editingInfo:. This new method receives an NSDictionary which contains a number of key-value pairs related to the chosen image/video; in your case, you'll want to check the value for UIImagePickerControllerMediaURL.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...