以编程方式启动相机进行视频录制

发布于 2024-10-22 18:03:10 字数 772 浏览 2 评论 0原文

我有一个快速的问题。我使用以下代码在 iOS 4.x 设备上启动相机并录制视频,效果很好。我想在 iPad 2 设备上使用相同的代码,因为 iPad 2 具有视频录制功能。它会起作用吗?有人可以指导我吗?

if ([types containsObject:(id)kUTTypeMovie])
{
    UIImagePickerController *pickerController = [[[UIImagePickerController alloc] init] autorelease];
    pickerController.delegate = self;
    pickerController.videoQuality = appDelegate.settingsCtrler.quality;
    pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    pickerController.showsCameraControls = YES;
    pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
    pickerController.videoMaximumDuration = maxDuration;
    [appDelegate hideFloatingBar];
    [self presentModalViewController:pickerController animated:YES];
}

先感谢您!

I have quick question. I am using the following code to launch camera and record video on iOS 4.x devices, it works great. I want to use the same code on iPad 2 device as iPad 2 has video recording facility. Will it work? Can someone please guide me?

if ([types containsObject:(id)kUTTypeMovie])
{
    UIImagePickerController *pickerController = [[[UIImagePickerController alloc] init] autorelease];
    pickerController.delegate = self;
    pickerController.videoQuality = appDelegate.settingsCtrler.quality;
    pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    pickerController.showsCameraControls = YES;
    pickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
    pickerController.videoMaximumDuration = maxDuration;
    [appDelegate hideFloatingBar];
    [self presentModalViewController:pickerController animated:YES];
}

Thank you in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦行七里 2024-10-29 18:03:10

如果它基于 iOS 4.3 构建,你应该没问题 - 尽管我没有 iPad2 来测试它。不过,我会将逻辑包装在测试中:

if([picker isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    // Your code here.
}

这样当相机不可用时,它就不会尝试显示相机。

If it builds on iOS 4.3 you should be OK - although I don't have an iPad2 to test it on. I would wrap the logic in a test though:

if([picker isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    // Your code here.
}

so that it doesn't try and present a camera when one isn't available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文