【问题标题】:ALAssetLibrary for audio用于音频的 ALAssetLibrary
【发布时间】:2012-10-16 14:25:59
【问题描述】:

我正在尝试通过这段代码使用 ALAssetLibrary 在我的应用程序中加载所有文件(音频、视频和图像):

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    // Within the group enumeration block, filter to enumerate everything.
    [group setAssetsFilter:[ALAssetsFilter allAssets]];
    // Accessing all the assets.

    for (int i = 0;i<[group numberOfAssets] ; i++) {

    [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:i] options:0 usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
        // The end of the enumeration is signaled by asset == nil
        if (alAsset) {
            ALAssetRepresentation *representation = [alAsset defaultRepresentation];
            NSURL *url = [representation url];
            NSLog(@"%@",url);
            AVAsset *avAsset = [AVURLAsset URLAssetWithURL:url options:nil];

            //Doing some stuff with assets

                       }
    }]; 
    }
}
failureBlock: ^(NSError *error) {
   NSLog(@"No groups");
 }];

但是,这只会加载视频和图像,而不是音频文件。我该怎么做?

【问题讨论】:

    标签: ios ios5 alassetslibrary alasset


    【解决方案1】:

    关于Apple.Developer ALAsset documentaionALAsset 对象表示由 Photo 应用程序管理的照片或视频

    资产可以有多种表现形式,例如以 RAW 和 JPG 格式拍摄的照片。同一资产的不同表现形式可能具有不同的维度。

    所以我认为,ALAssetsLibrary 不会检索您需要的内容:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-13
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多