1

我正在开发一个应用程序,其中我使用图像选择器控制器录制视频,视频录制限制设置为最多 2 秒。这是我在单击捕获视频以显示相机 UI 时的代码

-(IBAction)capture_btn_pressed:(id)sender
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"Message" message:@"camera is not supported for your device" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

    if (!cameraUI)
    {
        NSLog(@"camera ui");
        cameraUI = [[UIImagePickerController alloc] init];
        cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
        // Displays a control that allows the user to choose movie capture
        cameraUI.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];              
        cameraUI.delegate = self;
        cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
        cameraUI.videoMaximumDuration = 2;
        cameraUI.allowsEditing = YES;
    }

    [self presentModalViewController:cameraUI animated: YES];

}

我面临的问题: 视频录制的最大限制设置为 2 秒。因此,当我尝试单击 capturevideo 时,它将在 2 秒后自动停止。没关系,但有时它不会用视频录制背景音频。有时它会保存音频,但会保存 1 秒,然后休息一秒,它不会保存当时与视频一起播放的音频。我该如何解决这个问题任何帮助

4

0 回答 0