Home > DeveloperSection > Forums > How to get videos using ALAssetsLibrary in iOS?
Royce Roy
Royce Roy

Total Post:134

Points:938
Posted on    December-21-2015 12:13 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 319  View(s)
Rate this:
I was trying to get videos from the photo library because I also want to get images list so I am using ALAssetsLibrary. I have successfully get images from the photo library. But I have getting problem with the video because I am not understanding how can I do this.
Please help me.


Tarun Kumar

Total Post:210

Points:1614
Posted on    December-21-2015 10:54 PM

For getting videos ALAssetsFilter class is very helpful during enumeration on group,
Here is an example:

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    if(group){
        [group setAssetsFilter:[ALAssetsFilter allVideos]];
        [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
            if (asset){
                NSDictionary *meta = [[asset defaultRepresentation] metadata];
            }
        }];
    }
} failureBlock:^(NSError *error) {
    NSLog(@"Enumerating problem with AssetLibrary groups %@", error);
}];

We can also filter allPhotos, allAssets instead of allVideos.


Don't want to miss updates? Please click the below button!

Follow MindStick