2017-07-03 17 views
3

私はカスタム画像ピッカーを統合しているので、カメラのロールから10秒未満のビデオを表示する必要があります。以下のコードはギャラリーからすべての動画を取得しますが、期間に基づいてフィルタに述語を適用したいと考えています。継続時間が10秒未満のビデオを取得する

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() 

誰かが同じことを考えている場合は教えてください。おかげさまで

答えて

4

ちょうど述語

options.predicate = NSPredicate(format: "mediaType = %d AND duration < 10", PHAssetMediaType.video.rawValue) 
に条件を追加します
関連する問題