如何捕捉视频

时间:2012-06-04 06:45:49

标签: iphone ios video uiimagepickercontroller

如何录制视频

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];

我试过这个,但是我正在拍摄图像而我没有拍摄视频。

2 个答案:

答案 0 :(得分:2)

#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"]]
}
}

答案 1 :(得分:0)

显示imagePickerController后,启动设备的videoCapture。

有关详细信息,请参阅UIImagePickerController

的文档

您可以创建UIImagePickerController的子类。你可以在那里UIButton。在点击它时,您可以开始捕获视频。