Ios 获取持续时间小于10秒的视频
我正在集成自定义图像选择器,我必须显示持续时间不到10秒的摄像机滚动视频。下面的代码从gallery中获取所有视频,但我想根据持续时间将谓词应用于过滤器Ios 获取持续时间小于10秒的视频,ios,swift,video,core-data,phasset,Ios,Swift,Video,Core Data,Phasset,我正在集成自定义图像选择器,我必须显示持续时间不到10秒的摄像机滚动视频。下面的代码从gallery中获取所有视频,但我想根据持续时间将谓词应用于过滤器 let options = PHFetchOptions() options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true) ] options.predicate = NSPredicate(format: "mediaType
let options = PHFetchOptions()
options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true) ]
options.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.video.rawValue)
assets = PHAsset.fetchAssets(with: options)
print(assets ?? "no video found")
collectionView.reloadData()
如果有人对此有任何想法,请告诉我。
谢谢。只需将条件添加到谓词中即可
options.predicate = NSPredicate(format: "mediaType = %d AND duration < 10", PHAssetMediaType.video.rawValue)
options.predicate=NSPredicate(格式:“mediaType=%d,持续时间<10”,PHAssetMediaType.video.rawValue)