I am using PHCachingImageManager().requestAVAssetForVideo
to fetch videos from iPhone. I am not getting all the videos from my iPhone. Videos stored in Photos are being fetched not all.
How can I get all the videos stored in iPhone storage.
Here is the code.
let options = PHFetchOptions()
options.sortDescriptors = [NSSortDescriptor(key: "modificationDate",
ascending: true)]
let assetResults = PHAsset.fetchAssetsWithMediaType(.Video,
options: options)
for i in 0 ..< assetResults.count{
let object: AnyObject = assetResults[i]
if let asset = object as? PHAsset{
let options = PHVideoRequestOptions()
options.deliveryMode = .Automatic
options.networkAccessAllowed = true
options.version = .Current
options.progressHandler = {(progress: Double,
error: NSError?,
stop: UnsafeMutablePointer<ObjCBool>,
info: [NSObject : AnyObject]?) in
}
/* Now get the video */
PHCachingImageManager().requestAVAssetForVideo(asset,options: options,resultHandler: {(asset: AVAsset?,audioMix: AVAudioMix?,info: [NSObject : AnyObject]?) -> Void in dispatch_async(dispatch_get_main_queue(), {
/* Did we get the URL to the video? */
if let asset = asset as? AVURLAsset{
})
})
}
}