NSPredicate 从 PHFetchResults 中排除慢动作视频
NSPredicate to exclude slow motion videos from PHFetchResults
NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVideoHighFrameRate];
NSPredicate *predicate = [NSPredicate predicateWithFormat: predicateFormat];
PHFetchOptions *fetchOptions = [PHFetchOptions new];
fetchOptions.predicate = predicate;
PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumVideos options:fetchOptions];
这是我用来获取不包括慢动作视频的视频的代码。但是我正在关注 error.This 即使我这样做也不起作用,
PHFetchOptions *fetchOptions = [PHFetchOptions new];
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) == 0", PHAssetMediaSubtypeVideoHighFrameRate];
有人请帮助。提前致谢。
Unsupported predicate in fetch options: mediaSubtype == 131072
试试这个:
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype != %d)", PHAssetMediaSubtypeVideoHighFrameRate];
要排除慢动作视频,唯一对我有用的谓词是:
PHFetchOptions *options = [PHFetchOptions new];
// Disable slow motion videos
options.predicate = [NSPredicate predicateWithFormat:@"NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtypeVideoHighFrameRate];
Swift 4
let assetFetchOptions = PHFetchOptions()
assetFetchOptions.predicate = NSPredicate(format: "NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtype.videoHighFrameRate.rawValue)
NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVideoHighFrameRate];
NSPredicate *predicate = [NSPredicate predicateWithFormat: predicateFormat];
PHFetchOptions *fetchOptions = [PHFetchOptions new];
fetchOptions.predicate = predicate;
PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumVideos options:fetchOptions];
这是我用来获取不包括慢动作视频的视频的代码。但是我正在关注 error.This 即使我这样做也不起作用,
PHFetchOptions *fetchOptions = [PHFetchOptions new];
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype & %d) == 0", PHAssetMediaSubtypeVideoHighFrameRate];
有人请帮助。提前致谢。
Unsupported predicate in fetch options: mediaSubtype == 131072
试试这个:
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"(mediaSubtype != %d)", PHAssetMediaSubtypeVideoHighFrameRate];
要排除慢动作视频,唯一对我有用的谓词是:
PHFetchOptions *options = [PHFetchOptions new];
// Disable slow motion videos
options.predicate = [NSPredicate predicateWithFormat:@"NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtypeVideoHighFrameRate];
Swift 4
let assetFetchOptions = PHFetchOptions()
assetFetchOptions.predicate = NSPredicate(format: "NOT ((mediaSubtype & %d) != 0)", PHAssetMediaSubtype.videoHighFrameRate.rawValue)