0

I am trying to load all the files(audio, video and images) in my application using ALAssetLibrary by this piece of code:

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");
 }];

However, this only loads video and images, not the audio files. How can I do that?

1 Answers1

1

Regarding Apple.Developer ALAsset documentaion ,An ALAsset object represents a photo or a video managed by the Photo application.

Assets can have multiple representations, for example a photo which was captured in RAW and JPG. Different representations of the same asset may have different dimensions.

So i think ,ALAssetsLibrary will not retrieve what you need :)

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102