如何通过 Objective C 使用 iPhone 中的默认视频应用程序

发布于 2024-10-14 10:09:44 字数 101 浏览 1 评论 0原文

如何通过 Objective C 使用 iPhone 中的默认视频应用程序。 我想在我的应用程序中使用 iPhone 的默认视频应用程序,因为我之前已经使用过默认摄像头,但面临视频问题。

how to use default video application in iphone through objective c.
I want to used default video application of iphone in my application as I have already used default camera before but facing issues for video.

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

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

发布评论

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

评论(3

随遇而安 2024-10-21 10:09:44

假设您指的是媒体层< /a> 框架。

Assume you're referring to the media layer frameworks.

允世 2024-10-21 10:09:44

在摄像机上

使用代码UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = 自我; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; imagePicker.cameraCaptureMode=UIImagePickerControllerCameraCaptureModeVideo;

} [自我呈现ModalViewController:imagePicker动画:是];

} 别的 { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"No Camera Device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [警报显示]; [警报发布]; }

To on Video camera using code

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; imagePicker.cameraCaptureMode=UIImagePickerControllerCameraCaptureModeVideo;

} [self presentModalViewController:imagePicker animated:YES];

} else { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"No Camera Device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; }

隐诗 2024-10-21 10:09:44

将 MobileCoreServices 框架添加到您的项目中

#import 添加到您将在其中引用选取器的头文件中。
或者,您可以将导入添加到预编译头文件 (.pch),以便 UTCoreTypes 常量在整个项目中可用。

现在,在调用 UIImagePickerController 之前,只需将 mediaTypes 属性设置为电影类型 kUTTypeMovie 即可。或者,如果您只想显示照片,则可以使用 kUTTypeImage

myImagePickerController.mediaTypes =  
 [NSArray arrayWithObject:(NSString *)kUTTypeMovie];

请记住,您应该在设置 sourceType 之前检查设备是否支持视频录制,因为将其设置为设备上的电影类型不支持视频录制会造成各种破坏。您可以通过查看可用的源类型来做到这一点:

NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:myImagePickerController.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
   // no movie type supported...add code to handle that here.
}

Add the MobileCoreServices framework to your project

Add #import <MobileCoreServices/UTCoreTypes.h> to the header file where you will reference the picker.
Alternately, you can add the import to your precompiled header file (.pch) so the UTCoreTypes constants are available throughout the project.

Now, before calling the UIImagePickerController, just set the mediaTypes property to the movie type, kUTTypeMovie. Or, if you wanted to only display photos you would use kUTTypeImage:

myImagePickerController.mediaTypes =  
 [NSArray arrayWithObject:(NSString *)kUTTypeMovie];

Keep in mind that you should check if the device supports video recording before setting the sourceType, as setting it to a movie type on a device that does not support video recording will cause all sorts of havoc. You do that by looking at the available source types:

NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:myImagePickerController.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
   // no movie type supported...add code to handle that here.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文