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

纵然是瞬间 提交于 2019-12-18 05:22:07

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5514235/how-do-i-pick-and-record-video-using-uiimagepickercontroller-for-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!