ALAssetsGroupLibrary 不包含视频项

发布于 2024-12-12 02:01:47 字数 1089 浏览 0 评论 0原文

我使用 ALAssetLibrary 枚举设备上的视频,它对于在设备本身上创建的视频效果很好。但是,对于由于 iTunes 同步专辑/事件而创建的群组,我没有收到任何视频,尽管“视频”应用程序的对应目录中有视频。

搜索视频并记录每个组中的资产和视频数量的代码:

//using dispatch_async just to make sure it is called on the main thread

    dispatch_async(dispatch_get_main_queue(),^{

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];        

        [library enumerateGroupsWithTypes:ALAssetsGroupEvent|ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *group, BOOL *stop) {        

            if (group!=nil) {            

                NSLog(@"Number of assets in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);

                [group setAssetsFilter:[ALAssetsFilter allVideos]];        

                NSLog(@"Number of videos in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);

            }


        } failureBlock: ^(NSError *error) {

            NSLog(@"ERROR: %@",[error localizedDescription]);

        }]; 

    });

知道出了什么问题吗?或者如何获取从 iTunes 同步的视频? (iOS5与iPhone4)

I'm using the ALAssetLibrary to enumerate the videos on the device, and it works just fine for videos created on the device itself. But for groups that were created as a result of a synced album/event from iTunes I get no videos, although there are videos in the correspondence directory of the "Videos" app.

Code that search for videos and log the number of assets and videos in every group:

//using dispatch_async just to make sure it is called on the main thread

    dispatch_async(dispatch_get_main_queue(),^{

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];        

        [library enumerateGroupsWithTypes:ALAssetsGroupEvent|ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *group, BOOL *stop) {        

            if (group!=nil) {            

                NSLog(@"Number of assets in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);

                [group setAssetsFilter:[ALAssetsFilter allVideos]];        

                NSLog(@"Number of videos in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);

            }


        } failureBlock: ^(NSError *error) {

            NSLog(@"ERROR: %@",[error localizedDescription]);

        }]; 

    });

Any idea what's wrong? or how to get those videos that were synced from iTunes?
(iOS5 with iPhone4)

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

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

发布评论

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

评论(1

妖妓 2024-12-19 02:01:47

AssetsLibrary 仅枚举照片库。因此,您只能获取由“照片”应用程序管理的照片/视频(例如使用设备相机录制的视频)。 “视频”应用程序管理的视频位于不同的库中。官方开发者 API 无法访问这些内容。

干杯,

亨德里克

The AssetsLibrary only enumerates the Photo-Library. Therefore you only get photos/videos that are managed by the "Photos"-App (e.g. videos recorded with the device's camera). The videos managed by the "Videos" app are in a different Library. There is no way to access these by an official developer API.

Cheers,

Hendrik

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