如何使用iphone摄像头拍摄视频
我正在开发一个应用程序。因为我需要用相机拍摄视频。所以请告诉我怎么做。仔细阅读。它将告诉您如何解决问题。我假设您知道如何使用如何使用iphone摄像头拍摄视频,iphone,Iphone,我正在开发一个应用程序。因为我需要用相机拍摄视频。所以请告诉我怎么做。仔细阅读。它将告诉您如何解决问题。我假设您知道如何使用UIImagePickerController #import <MediaPlayer/MediaPlayer.h> // add MediaPlayer.framework - (IBAction) startCamera { UIImagePickerController * startCamera; startCamera = [[UI
UIImagePickerController
#import <MediaPlayer/MediaPlayer.h> // add MediaPlayer.framework
- (IBAction) startCamera
{
UIImagePickerController * startCamera;
startCamera = [[UIImagePickerController alloc] init];
startCamera.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
NSArray *mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
startCamera.mediaTypes = mediaTypes ;
startCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
startCamera.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo ;
startCamera.allowsEditing = YES ;
}
else
{
startCamera.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:startCamera animated:YES];
[startCamera release];
}
#导入//添加MediaPlayer.framework
-(IBAction)startCamera
{
UIImagePickerController*startCamera;
startCamera=[[UIImagePickerController alloc]init];
startCamera.delegate=self;
如果([UIImagePickerController IsSourceType可用:UIImagePickerController SourceType相机])
{
NSArray*mediaTypes=[NSArray arrayWithObject:(NSString*)kUTTypeMovie];
startCamera.mediaTypes=媒体类型;
startCamera.sourceType=UIImagePickerControllerSourceTypeCamera;
startCamera.cameraCaptureMode=UIImagePickerControllerCameraCaptureModeVideo;
startCamera.allowsEditing=是;
}
其他的
{
startCamera.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
[自我呈现ModalViewController:startCamera动画:是];
[startCamera发布];
}
试试这个代码片段。仅在设备中测试此代码。使用UIImagePickerDelegate方法处理录制的视频
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]))
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController: picker animated:YES];
}
else
{
NSLog(@"Put alert no camer found");
// Put alert no camer found
}
[picker release];