在 OS 3.1 中使用 UIImagePickerController 从 PhotoLibrary 中选取视频

发布于 2024-08-07 12:25:06 字数 358 浏览 5 评论 0原文

我正在尝试从照片库中选择一个视频。原则上我知道如何做到这一点,您将图像选择器的 mediaType 设置为 NSArray,并以 kUTTypeMovie 作为其唯一对象。 但这似乎不适用于 iPhone 3G。从 OS 3.1 开始,您可以将收到的视频存储在照片库中。当您在“照片”应用程序中开始构建时,会出现视频。然而,这在使用 UIImagePickerController 时不起作用。控制器报告它仅支持图像。当您尝试使用 kUTTypeMovie 设置控制器的媒体类型时,它实际上会崩溃。

如果您不指定媒体类型,则选择器中仅显示图像。

有人设法从照片库中挑选视频吗?如果是的话,它只适用于 3gs 还是也适用于 3G?

问候

I am trying to pick a video from the photo library. In principle I know how to do it you set the mediaType of the image picker to an NSArray with kUTTypeMovie as its only object.
But this doesn't seem to work on an iPhone 3G. Since OS 3.1 you can store videos you've received in your photo library. When you start the build in 'Photos' application the videos appear. However this doesn't work using the UIImagePickerController. The controller reports that it only supports images. When you try to set the mediaType of the controller with kUTTypeMovie it actually crashes.

If you don't specify the media type only images are shown in the picker.

As anyone managed to pick a video from the photo library? If yes did it only work on the 3gs or on the 3G as well?

Regards

Ben

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

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

发布评论

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

评论(2

萌辣 2024-08-14 12:25:06

我让图像选择器在 3g 和 3gs 上工作来选择视频。

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imgPicker setMediaTypes:mediaTypesAllowed];

并获取所选视频

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:@"public.movie"]){...}
}

I got the imagepicker working on a 3g and a 3gs to pick videos.

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imgPicker setMediaTypes:mediaTypesAllowed];

And to get the picked video

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:@"public.movie"]){...}
}
笨死的猪 2024-08-14 12:25:06

嘿,我也无法使用上述代码获取 3G 上的电影对象。我的 3G 上就崩溃了。不过,它可以在我的 3GS 上运行,但问题是它在照片库中显示图像和电影的混合。我尝试了以下代码:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

在运行 OS 3.1.2 的 3GS 上,它向我显示存储在我的照片库中的视频和图像。

而如果我尝试执行以下操作:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.movie"];
[videoPickerCtrl setMediaTypes:mediaTypesAllowed];

那么它向我显示的只是存储在相机胶卷中的视频,而没有其他内容。有人可以帮忙吗?

Hey, I am also unable to get movie objects on 3G using the above mentioned code. It crashes on my 3G. It however works on my 3GS, but the issue is it shows a mix of both images and movies in photo library. I tried the following code:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

and on my 3GS running OS 3.1.2, it shows me videos cum images stored in my photo library.

Whereas if I try doing the following:

videoPickerCtrl.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.movie"];
[videoPickerCtrl setMediaTypes:mediaTypesAllowed];

Then all it shows me is videos stored in Camera Roll, and nothing else. Can somebody help ?

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