PHAsset fetchAssetsWithMediaType: PHAssetMediaTypeVideo does not return video on iOS 10.2

This is exactly the same as this PHAsset fetchAssetsWithMediaType question : PHAssetMediaTypeVideo does not return video on iOS 8.1

except that the solution does not work.

    NSMutableArray *filteredAssets = [NSMutableArray array];

PHFetchOptions *options = [[PHFetchOptions alloc] init];
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:options];

for (id collection in albums) {
    PHFetchResult *videos = [PHAsset fetchAssetsInAssetCollection:collection options:nil];
    for (id a in videos)
    {
        if ([a isKindOfClass:[PHAsset class]])
        {
            PHAsset *asset = a;
            if ([asset mediaType] != PHAssetMediaTypeVideo) {
                NSLog(@"%@ %ld", [asset localIdentifier], (long)[asset mediaType]);
                continue;
            }

vvvvvvvvvvvvvvv I never end here. Type 1 hysterical assets (photographs) are repeated. Videos recently updated from the Photos in Video app are not displayed.

            if (![filteredAssets containsObject:asset]) // prevents duplicates if asset is contained in multiple collections
                [filteredAssets addObject:asset];
        }
    }
}

and simpler

PHFetchResult<PHAsset*> *videos = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];

also returns null videos

0
source share

All Articles