Hi, I would like to know how to retrieve the file size of a video using AssetLibrary? Can anyone point me in the right direction? or possible some code snippet?
+1
A:
This should get you on the right track. See Assets Library Framework Reference
- (void)logVideoSizes {
void (^assetEnumerator)(ALAsset *asset, NSUInteger index, BOOL *stop) {
if(asset != nil)
ALAssetsRepresentation* representation = [asset defaultRepresentation];
NSLog(@"Size = %d", [representation size]);
}
void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {
NSLog(@"A problem occured");
}];
[library release];
}
Rod
2010-10-14 03:22:50
Hey, it works! Thanks a lot.
tan
2010-10-14 11:02:49