我正在开发一个应用程序,其中我使用图像选择器控制器来录制视频,视频录制限制设置为最多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秒钟,然后在休息1秒钟时,它不会保存播放视频的音频。 我怎么能解决这个问题的任何帮助