Reputation: 585
I have found a lot of solutions, but all of them are implemented with ALAssetLibrary, But the assetlibrary will be depreciated in iOS 9, I do not know how to get video files in photo library, and get their url and thumbnail.
Upvotes: 2
Views: 3938
Reputation: 12664
You can also use the function fetchAssets with media type
Video
let videosArray = PHAsset.fetchAssets(with: .video, options: nil)
Images
let imagesArray = PHAsset.fetchAssets(with: .image, options: nil)
Upvotes: 3
Reputation: 21805
You could play around with the sample code Apple provides for photo kit
Code would be something like
PHPhotoLibrary.requestAuthorization { (status) -> Void in
let allVidOptions = PHFetchOptions()
allVidOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.Video.rawValue)
allVidOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
let allVids = PHAsset.fetchAssetsWithOptions(allVidOptions)
for index in 0..<allVids.count {
//fetch Asset here
print(allVids[index])
}
}
Upvotes: 3