0

我想列出所有視頻。不僅僅是照片庫中的視頻,還有視頻應用程序,包括電影,電視節目,音樂視頻等等。在(*的UITableViewCell)的tableView列出所有視頻(從照片庫和視頻應用)到uitableviewcell

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]]]; 

:的cellForRowAtIndexPath:

當我用ALAsset這樣的方法,只在照片庫中的視頻會顯示出來。有沒有辦法獲得所有類型?提前

感謝

回答

0

我猜你需要以檢索iOS設備上的所有視頻,你可以找到相同in this post

+1

這不會從視頻應用中提取視頻 – 2013-12-03 16:57:53

+0

它只會從照片庫(iPod庫)中獲取所有視頻,而不是從其他應用獲取.-好運 – 2013-12-04 04:05:22

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