我们的应用程序允许用户从他们的相机胶卷中加载视频。这是非常标准的东西:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
// Enumeration over all groups with videos
ALAssetsLibraryGroupsEnumerationResultsBlock groupsEnumerationBlock = ^(ALAssetsGroup *group, BOOL *stop)
{
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if (result) {
// do stuff here with each video
}
}];
};
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock: groupsEnumerationBlock
failureBlock:^(NSError *error) {
log4Debug(@"No groups found or accessible for Camera Roll.");
}
];
问题当然出在 iOS8 上。该代码枚举了 iOS7 下的所有视频,但在 iOS8 下,它枚举了所有最近的视频。超过 30 天的视频不可用。
事实上,当您在 iOS8 下查看照片应用程序时,您甚至都看不到相机胶卷,而只是一张“最近添加”的相册。现在,还有一个包含所有视频的“视频”专辑。在这里访问它会很好。
我们无法转换为 PhotoKit(今天)。我们很快就会这样做,但现在我们需要一个适用于 iOS7 和 iOS8 的解决方案。