UIImagePicker StartVideo问题

时间:2011-07-04 10:22:28

标签: iphone uiimagepickercontroller

我正在使用叠加按钮在iPad上开始录制视频。

当我调用[imagePickerController startVideoCapture]时,我得到“takevideo活动指示已经清除”

iPad无法开始录制。再次调用startVideoCapture后开始录制。 以下是我的代码。任何帮助将不胜感激。

- (IBAction)startStop:(id)sender
{
    if (isCapturingVideo)
    {
         isCapturingVideo = FALSE;
        [self.imagePickerController stopVideoCapture];
    }

    else if (!isCapturingVideo)
    {   

        NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        NSArray *videoMediaTypesOnly = [mediaTypes filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(SELF contains %@)", @"movie"]];

        if ([videoMediaTypesOnly count] == 0)       //Is movie output possible?
        {
            UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Sorry but your device does not support video recording"
                                                                     delegate:nil
                                                            cancelButtonTitle:@"OK"
                                                       destructiveButtonTitle:nil
                                                            otherButtonTitles:nil];
            [actionSheet showInView:[[self view] window]];
            [actionSheet autorelease];
        }
        else
        {

            self.imagePickerController.mediaTypes = videoMediaTypesOnly;
            self.imagePickerController.videoQuality = UIImagePickerControllerQualityTypeMedium;
            self.imagePickerController.videoMaximumDuration = 180;
            self.imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
            self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
            isCapturingVideo = TRUE;
            BOOL result = [self.imagePickerController startVideoCapture];
            NSLog(@"Result Camera: %@", result?@"YES":@"NO");

        }


    }
}

1 个答案:

答案 0 :(得分:0)

我认为它与代码中的isCapturingVideo标志有关。文档说Calling this method while a movie is being captured has no effect.
我怀疑该标志没有得到正确更新。您可以尝试在开始之前强制关闭(使用stopVideoCapture)视频并查看它是否有效。

相关问题