使用 AssetsLibrary 框架 iPhone 访问库中的视频? [英] Accessing Videos in library using AssetsLibrary framework iPhone?

查看:7
本文介绍了使用 AssetsLibrary 框架 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 是 3G 升级到 iPhone 4.1.(但资产框架没有给出任何错误)

by the way 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.

这篇关于使用 AssetsLibrary 框架 iPhone 访问库中的视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆