iphone - ios中的视频捕获问题

标签 iphone ios ipad camera

<分区>

Possible Duplicate:
recored video using UIImagePickerController

我是 iOS 开发的新手。现在我正在开发视频录制应用程序。但我的应用有时会录制视频。有时它会关闭相机给我警告

UIImagePickerController: ignoring request to stop video capture; camera is not currently capturing video.

最佳答案

我正在捕获视频并像这样存储在文档目录中:-

-(IBAction)cameraLibraryButtonClick:(id)sender{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {              
        UIImagePickerController *videoRecorder = [[UIImagePickerController alloc]init];  
        videoRecorder.delegate = self;
        NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:videoRecorder.sourceType];
        NSLog(@"Available types for source as camera = %@", sourceTypes);
        if (![sourceTypes containsObject:(NSString*)kUTTypeMovie] ) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil 
                                                            message:@"Device Not Supported for video Recording."                                                                       delegate:self 
                                                  cancelButtonTitle:@"Yes" 
                                                  otherButtonTitles:@"No",nil];
            [alert show];
            [alert release];
            return;
        }
        videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
        videoRecorder.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];           
        videoRecorder.videoQuality = UIImagePickerControllerQualityTypeLow;
        videoRecorder.videoMaximumDuration = 120;

        self.imagePicker = videoRecorder;                 
        [videoRecorder release];
        [self presentModalViewController:self.imagePicker animated:YES];
        newMedia = YES;
    }
    else {
        [self displaysorceError];
    }


}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
        NSData *videoData = [NSData dataWithContentsOfURL:videoURL];
        //self.fileManager = [NSFileManager defaultManager];
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory , NSUserDomainMask, YES);

        NSString *ZipLibrary = [paths objectAtIndex:0];


    NSString *FileFullPath = [ZipLibrary stringByAppendingPathComponent:@"%@.mp4"];

    NSLog(@"Ziplinrnr oadfjaidfjidfjidjfid %@",FileFullPath);
        [videoData writeToFile:FileFullPath atomically:YES];

    [self dismissModalViewControllerAnimated:YES];

}


-(void)displaysorceError{
    UIAlertView *alt = [[UIAlertView alloc] 
                        initWithTitle:@"Error" 
                        message:@"Camera Image Sorce Not Available" 
                        delegate:nil cancelButtonTitle:@"OK" 
                        otherButtonTitles:nil];
    [alt show];
    [alt release];
}

关于iphone - ios中的视频捕获问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13250718/

相关文章:

ios - 核心数据 Perform() performAndWait() 100% 不确定

ios - NSURLSession 因使用 TLS 1.2 的 SSL 页面而失败

ios - 自定义过渡时的黑色背景

ios - iOS 上的 resolveLocalFileSystemURL 每次使用不同的 App UUID

ipad - ASP.NET list 文件脚本未刷新

iphone - Interface Builder 与 iPhone 上显示的内容对比

iphone - UIImageView autoresizingMask 行为

html - 响应式英雄形象不适用于 iPhone

iphone - 如何缩小从远程服务器加载的非视网膜 iPhone 的视网膜图像?

iphone - 带有弯曲端的iOS Draw Rectangle