2012-10-16 14 views
0

我想通過這段代碼加載的所有文件(音頻,視頻和圖像)的使用ALAssetLibrary我的應用程序: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"); 
}]; 

然而,這僅僅加載視頻和圖像,而不是音頻文件。我怎樣才能做到這一點?

回答

1

關於Apple.Developer ALAsset documentaion,一種ALAsset對象表示照片或照片應用所管理的視頻

資產可以有多個表示,例如以RAW和JPG格式捕獲的照片。同一資產的不同表示可能具有不同的維度。

所以我認爲,ALAssetsLibrary不會檢索你需要的東西:)