0

I want to list all the videos. Not just the videos in photo library, but also in the video app, including the movies, tv shows, music videos, etc into my app.

When I used ALAsset like this:

ALAsset *asset = [videoLibrary objectAtIndex:indexPath.row];
videoURL = [[asset defaultRepresentation] url];
[videoURLs addObject:videoURL];
[cell.textLabel setText:[NSString stringWithFormat:@"Video %d", indexPath.row+1]];
[cell.imageView setImage:[UIImage imageWithCGImage:[asset thumbnail]]];

in the (UITableViewCell *)tableView:cellForRowAtIndexPath: method, only the video in the photo library will show up. Is there a way to get all the types?

Thanks in advance

the_summer_bee
  • 483
  • 4
  • 10
  • 23

2 Answers2

0

I guess you need to retrive all the videos on your IOS devices, you can find the code for same in this post

Community
  • 1
  • 1
Dipen Panchasara
  • 13,480
  • 5
  • 47
  • 57
0

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
    NSMutableArray *assetURLDictionaries = [[NSMutableArray alloc] init];

    // Process assets
    void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        if (result != nil) {   
           if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]){
                [assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
                NSURL *url = result.defaultRepresentation.url;
                [assetLibrary assetForURL:url
                              resultBlock:^(ALAsset *asset) {
                                  if (asset) {
                                      @synchronized(assets) {
                                          [systemVideoArray addObject:asset];
                                          [self.mTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
                                      }
                                  }
                              }
                             failureBlock:^(NSError *error){
                                 NSLog(@"operation was not successfull!");
                             }];
            }
        }
    };
iPermanent
  • 51
  • 2