Retrieve only video of particular album from library ios

668 views Asked by At

I want the list of video that are stored in particular Album like that(VideoMaker) . This list is in array of URL.

  • This list show in uicollectionview

I write this code..for to retrieve the video but it gives null value of URL.

[_library enumerateGroupsWithTypes:ALAssetsGroupAll  usingBlock:^(ALAssetsGroup *group, BOOL *stop){

    NSLog(@"succed");
    if (group != NULL) {

                    [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index,BOOL *st){


                        if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
                            NSLog(@"asset: %@", result);
                            [assets addObject:result];
                        }

                    }];
                }

                [self.collectionView reloadData];
    } failureBlock:^(NSError *error) {
    NSLog(@"Failure");
    }];

In this code _library is(ALAssetLibrary) and assets is(NSMutableArray) I created one Album in my Iphone so I want get only this video that is stored in my Album.

1

There are 1 answers

0
Milan patel On BEST ANSWER

I add the assetfilter in this. with the propertyname

The new code is:

    [_library enumerateGroupsWithTypes:ALAssetsGroupAll  usingBlock:^(ALAssetsGroup *group, BOOL *stop){

        if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqual:@"VideoMaker"]) {

            [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop){
                [group setAssetsFilter:[ALAssetsFilter allVideos]];

                if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo])  {
                    NSLog(@"asset: %@", result);

                    [assets addObject:result];
                }

            }];
        }

        [self.collectionView reloadData];
        //[self.activity stopAnimating];
        //[self.activity setHidden:YES];

    }
                         failureBlock:^(NSError *error){

                             NSLog(@"failure"); }];
}