使用AssestsLibrary框架iPhone访问库中的视频? [英] Accessing Videos in library using AssestsLibrary framework iPhone?
问题描述
我正在尝试使用AssetsLibrary框架在以下代码的帮助下访问iPhone库中的视频...但是当我运行应用程序时代码无效...数组资产仍然是空的?我做错了什么?
i am trying to access videos in iPhone library using AssetsLibrary Framework with the help of following code...but when i run the application the code is not working...the array assets is still empty?? what am i doing wrong??
顺便说一句我的iPhone是升级到iPhone 4.1的3G。(但资产框架没有给出任何错误)
btw my iPhone is a 3G upgraded to iPhone 4.1.(but assets framework is not giving any error)
NSMutableArray *assets = [[NSMutableArray alloc]init];
ALAssetsLibrary *library =[[ALAssetsLibrary alloc]init];
void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != NULL) {
NSLog(@"See Asset: %@", result);
[assets addObject:result];
}
};
void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {NSLog(@"dont See Asset: ");
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
assets = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"Failure");
}];
推荐答案
4.1升级似乎已破坏了一些图像选择器示例,请观察以下行,这些行在您发布的代码之后运行:
the 4.1 upgrade seems to have 'broken' some of the image picker examples, observe the following lines, which run after the code you have posted:
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupEvent | ALAssetsGroupFaces;
[assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock];
这在我的4.1 iPhone和模拟器上都提供零资产。但是,更改groupTypes有帮助,所以设置
This gives zero assets both on my 4.1 iPhone and simulator. However changing the groupTypes helps, so set
NSUInteger groupTypes = ALAssetsGroupAll;
您应该开始看到一些资产。
and you should start seeing some assets.
这篇关于使用AssestsLibrary框架iPhone访问库中的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!