我正在尝试获取所有时长超过 1.5 秒的视频。
我尝试过的
let videoOptions = PHFetchOptions()
let dur : Double = 1.5
videoOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
videoOptions.predicate = NSPredicate(format: "mediaType = %d AND duration > %d", PHAssetMediaType.Video.rawValue,dur)
VideoCollectionFetchResult = PHAsset.fetchAssetsWithOptions(videoOptions)
文档说:
有什么建议吗?谢谢!
最佳答案
与格式有关——duration实际上是Double格式,%d是整数。尝试使用 %f,例如:
(format: "mediaType = %d AND duration > %f", PHAssetMediaType.Video.rawValue,dur)
关于objective-c - PHFetchOptions 持续时间无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36718262/