ALAssetsGroupSavedPhotos latest, not all, videos in iOS8

Our application allows the user to download videos from their camera roll. This is pretty standard stuff:

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.");
                     }
 ];

      

The problem is of course iOS8. This code lists all videos in iOS7, but in iOS8 it lists all the latest videos. Videos older than 30 days are not available.

In fact, when you look at the Photos app under iOS8, you no longer see the Camera Roll, but just a "recently added" album. Now there is also a "Videos" album, which contains all the videos. Accessing this will be fine.

We cannot convert to PhotoKit (today). We'll want to do this soon, but right now we need a solution that works with both iOS7 and iOS8.

+3


source to share


1 answer


Have you tried this:

PHFetchOptions *allPhotosOptions = [PHFetchOptions new];
allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];

PHFetchResult *allPhotosResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:allPhotosOptions];

      



When I tested this on my device, it returned all the videos I have on the device, not just the latest.

0


source







All Articles