ALAssetsLibrary获取所有视频 [英] ALAssetsLibrary get all videos

查看:96
本文介绍了ALAssetsLibrary获取所有视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个相机应用程序,以获取用户在其iPhone上创建的所有视频.

I am making a camera app where I want to get to all of the videos users have created on their iPhone.

目前,我所拥有的代码仅从用户Camera Roll获取视频.我的一些用户抱怨他们在相册"应用程序下创建了多个自定义文件夹,并且在其中存储了一些视频.由于我的代码仅查看相机胶卷",因此不会从其他文件夹中拾取影片.我可以进入他们的其他文件夹吗?

Currently the code I have gets the videos from user Camera Roll only. Some my users have complained that they have multiple custom folders created under their Photo Album app and they store some videos in there. Since my code only looks at Camera Roll, it doesn't pickup the movies from their other folders. Is it possible that I can get to their other folders?

这是我到目前为止所拥有的.

This is what I have so far.

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop)
     {
         [group enumerateAssetsUsingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop)
         {
              if (alAsset)
              {
                  ALAssetRepresentation *representation =[alAsset defaultRepresentation];
                  NSURL *url = [representation url];
                  NSString *assetType=[alAsset valueForProperty:ALAssetPropertyType];


                  //videos only
                  if ([assetType isEqualToString:@"ALAssetTypeVideo"])
                  {
                   .....

推荐答案

您必须为资产创建一个过滤器,如下所示:

You got to create a filter for the assets, something like this:

ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {  

    ALAssetsFilter *allVideosFilter = [ALAssetsFilter allVideos];
    [group setAssetsFilter:allVideosFilter];
    //...
};

过滤器的选项是:-allAssets-全部影片-allPhotos

Options for filters are: - allAssets - allVideos - allPhotos

希望这会有所帮助

这篇关于ALAssetsLibrary获取所有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆