Milan patel
Milan patel

Reputation: 223

Retrieve only video of particular album from library ios

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

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.

Upvotes: 1

Views: 669

Answers (1)

Milan patel
Milan patel

Reputation: 223

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

Upvotes: 1

Related Questions