HOW TO GET VIDEOS USING ALASSETSLIBRARY IN IOS?

Royce Roy

Total Post:149

Points:1043
Posted by  Royce Roy
 727  View(s)
Ratings:
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.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How to get videos using ALAssetsLibrary in iOS?

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!