ALAssetsGroupLibrary 不包含视频项
我使用 ALAssetLibrary 枚举设备上的视频,它对于在设备本身上创建的视频效果很好。但是,对于由于 iTunes 同步专辑/事件而创建的群组,我没有收到任何视频,尽管“视频”应用程序的对应目录中有视频。
搜索视频并记录每个组中的资产和视频数量的代码:
//using dispatch_async just to make sure it is called on the main thread
dispatch_async(dispatch_get_main_queue(),^{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupEvent|ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group!=nil) {
NSLog(@"Number of assets in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);
[group setAssetsFilter:[ALAssetsFilter allVideos]];
NSLog(@"Number of videos in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);
}
} failureBlock: ^(NSError *error) {
NSLog(@"ERROR: %@",[error localizedDescription]);
}];
});
知道出了什么问题吗?或者如何获取从 iTunes 同步的视频? (iOS5与iPhone4)
I'm using the ALAssetLibrary to enumerate the videos on the device, and it works just fine for videos created on the device itself. But for groups that were created as a result of a synced album/event from iTunes I get no videos, although there are videos in the correspondence directory of the "Videos" app.
Code that search for videos and log the number of assets and videos in every group:
//using dispatch_async just to make sure it is called on the main thread
dispatch_async(dispatch_get_main_queue(),^{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupEvent|ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group!=nil) {
NSLog(@"Number of assets in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);
[group setAssetsFilter:[ALAssetsFilter allVideos]];
NSLog(@"Number of videos in %@ :%d",[group valueForProperty:ALAssetsGroupPropertyName],[group numberOfAssets]);
}
} failureBlock: ^(NSError *error) {
NSLog(@"ERROR: %@",[error localizedDescription]);
}];
});
Any idea what's wrong? or how to get those videos that were synced from iTunes?
(iOS5 with iPhone4)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AssetsLibrary 仅枚举照片库。因此,您只能获取由“照片”应用程序管理的照片/视频(例如使用设备相机录制的视频)。 “视频”应用程序管理的视频位于不同的库中。官方开发者 API 无法访问这些内容。
干杯,
亨德里克
The AssetsLibrary only enumerates the Photo-Library. Therefore you only get photos/videos that are managed by the "Photos"-App (e.g. videos recorded with the device's camera). The videos managed by the "Videos" app are in a different Library. There is no way to access these by an official developer API.
Cheers,
Hendrik