【问题标题】:list all the videos (from the photo library and the video app) into the uitableviewcell将所有视频(来自照片库和视频应用程序)列出到 uitableviewcell
【发布时间】:2013-04-23 12:49:24
【问题描述】:

我想列出所有视频。不仅是照片库中的视频,还有视频应用程序中的视频,包括电影、电视节目、音乐视频等进入我的应用程序。

当我像这样使用 ALAsset 时:

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

在 (UITableViewCell *)tableView:cellForRowAtIndexPath: 方法中,只会显示照片库中的视频。有没有办法获取所有类型?

提前致谢

【问题讨论】:

    标签: objective-c uitableview alassetslibrary alasset mpmediaquery


    【解决方案1】:

    我猜你需要在你的IOS设备上检索所有视频,你可以找到相同in this post的代码

    【讨论】:

    • 这不会从视频应用中提取视频。
    • 它只会从照片库(iPod 库)中获取所有视频,而不是从其他应用程序中获取所有视频。-祝你好运
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      • 2012-05-24
      • 1970-01-01
      • 2011-05-28
      相关资源
      最近更新 更多