我已经实现了代码来执行视频录制功能。它在3GS设备上运行良好。我想根据一些计时器设置来限制视频录制。可以说,我想让用户只进行20秒或35秒的视频录制。我怎样才能做到这一点?我可以在录制视频时在媒体播放器顶部显示计时器控件吗?
请建议我。
以下是我的视频录制代码:
UIImagePickerController *pickerController =
[[[UIImagePickerController alloc] init] autorelease];
pickerController.delegate = self;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.showsCameraControls = YES;
pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
[self presentModalViewController:pickerController animated:YES];
答案 0 :(得分:6)
videoMaximumDuration
需要NSTimeInterval
,这是浮点值的tpyedef。所以你应该传递一个浮点值。试试这样:
UIImagePickerController *pickerController = [[UIImagePickerController alloc] init];
pickerController.delegate = self;
pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerController.showsCameraControls = YES;
pickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; // kUTTypeMovie is actually an NSString.
pickerController.videoMaximumDuration = 30.0f; // limits video length to 30 seconds.
[self presentModalViewController:pickerController animated:YES];
[pickerController release];
答案 1 :(得分:0)
UIImagePickerController
类的属性videoMaximumDuration
适用于NSTimeInterval
。
默认情况下,其值设置为 10分钟,但您可以根据需要更改浮动值。
因此,如果您创建名为UIImagePickerController
的{{1}}类的对象,那么您可以设置用于捕获视频的计时器 -
videoPickerController