“不支持这种电影格式” - iPad上的UIImagePickerController的奇怪问题(iOS v 4.3)

时间:2011-11-14 21:59:07

标签: iphone objective-c ios ipad ios4

我的基本要求是使用UIImagePickerController捕获视频。录制10秒视频后,视频录制应自动停止。

我在iPad 2上遇到了非常奇怪的错误(iOS版本4.3) - 当视频在iPad2上达到最大持续时间时,“不支持此电影格式”。

这是我的一段代码。该代码在iPhone上运行得非常好,但是当视频在iPad2上达到其最大持续时间时,会给出“不支持此电影格式”。

非常感谢任何帮助。

(void) launchCamera : (BOOL) bAlbum         
    {   
    UIImagePickerController * pImgPicker = [[UIImagePickerController alloc] init];  
    pImgPicker.delegate = self;

    pImgPicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:pImgPicker.sourceType];
    if(m_bRecordVideo)
    {
        pImgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [pImgPicker setVideoQuality: UIImagePickerControllerQualityTypeMedium];
        [pImgPicker setCameraCaptureMode: UIImagePickerControllerCameraCaptureModeVideo];
        [pImgPicker setVideoMaximumDuration:10];
    }
    else
    {
        pImgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [pImgPicker setCameraCaptureMode: UIImagePickerControllerCameraCaptureModePhoto];
    }

    [self presentModalViewController:pImgPicker animated:YES];
    [pImgPicker release];
}

1 个答案:

答案 0 :(得分:0)

我找到了上述问题的解决方案。

以下一行解决了这个问题。

pImgPicker.mediaTypes = [[[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie,nil] autorelease];

这是更新的代码。

-(void) launchCamera : (BOOL) bAlbum
{
    UIImagePickerController * pImgPicker = [[UIImagePickerController alloc] init];
    pImgPicker.delegate = self;

    pImgPicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:pImgPicker.sourceType];
    if(m_bRecordVideo) 
    {
        pImgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        pImgPicker.mediaTypes = [[[NSArray alloc] initWithObjects:(NSString*) kUTTypeMovie, nil] autorelease];

        [pImgPicker setVideoQuality: UIImagePickerControllerQualityTypeMedium];
        [pImgPicker setCameraCaptureMode: UIImagePickerControllerCameraCaptureModeVideo];
        [pImgPicker setVideoMaximumDuration:10];
    }
    else
    {
        pImgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [pImgPicker setCameraCaptureMode: UIImagePickerControllerCameraCaptureModePhoto];
    }

    [self presentModalViewController:pImgPicker animated:YES];
    [pImgPicker release];
}

谢谢, --Prem