Created
February 9, 2015 15:42
-
-
Save victusfate/e0e62a6d639f9b664649 to your computer and use it in GitHub Desktop.
example from @marcvanolmen and @chris for loading assets with PHImageManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let imageManager = PHImageManager.defaultManager() | |
let videoRequestOptions = PHVideoRequestOptions() | |
videoRequestOptions.deliveryMode = .HighQualityFormat | |
videoRequestOptions.version = .Current | |
videoRequestOptions.networkAccessAllowed = true | |
videoRequestOptions.progressHandler = { (progress: Double, error: NSError!, stop: UnsafeMutablePointer<ObjCBool>, [NSObject : AnyObject]!) -> Void in | |
NSLog("Progress: %@", progress.description) | |
} | |
videoRequestOptions.progressHandler = { (progress: Double, error: NSError!, stop: UnsafeMutablePointer<ObjCBool>, [NSObject : AnyObject]!) -> Void in | |
NSLog("Progress: %@", progress.description) | |
} | |
imageManager.requestAVAssetForVideo(nextAsset, options: videoRequestOptions, resultHandler: { (avAsset: AVAsset!, avAudioMix: AVAudioMix!, info: [NSObject : AnyObject]!) -> Void in | |
if let nextURLAsset = avAsset as? AVURLAsset { | |
let sourceURL = nextURLAsset.URL | |
if NSFileManager.defaultManager().fileExistsAtPath(sourceURL.path!) { | |
NSLog("exist file") | |
} | |
var data = NSData(contentsOfURL: sourceURL) | |
if let aData = data { | |
NSLog("length : <\(aData.length)") | |
} | |
else { | |
NSLog("no data read.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment