开发者

load the video type in the photo album using AssetsLibrary in objective C

i came across the following piece of code which loads everything from photo album but what should i do if i only wanted to l开发者_JAVA技巧oad the video type in the photo album on a table?

thanks in advance.

void (^assetEnumerator)(struct ALAsset *,NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop){
        if(result != nil){
            NSLog(@"Asset:%@", result);
            [Asset addObject:result];
        }
    };

    void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop){
        if(group != nil){
            [group enumerateAssetsUsingBlock: assetEnumerator];
        }

        [self.tableView reloadData];


    };

    Asset = [[NSMutableArray alloc] init];
    ALAssetsLibrary *Library = [[ALAssetsLibrary alloc] init];
    [Library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                           usingBlock:assetGroupEnumerator 
                         failureBlock:^(NSError *error){
                             NSLog(@"error occurred");
                         }];


Have a look at the -valueForProperty: instance method of ALAsset. Specifically, in your example with ALAsset *result:

if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
    // asset is a video
}


I think this will be better.

if ([result valueForProperty:ALAssetPropertyType] == ALAssetTypeVideo) {
    // asset is a video
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜