我的基本要求是使用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];
}
答案 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