0
大家好我正在使用ALAssetsLibrary將視頻/圖像寫入相冊。 但XCode告訴我ALAssetsLibrary已被棄用,我需要使用PHPhotoLibrary,這一切都很好,但沒有關於如何進行此轉換的示例或文檔。如何使用PHPhotoLibrary將視頻/圖像寫入保存的照片相冊?
任何人都可以告訴我如何更改此代碼使用PHPHotoLibrary?
let data:NSData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageDataSampleBuffer)
let image:UIImage = UIImage(data: data)!
let library:ALAssetsLibrary = ALAssetsLibrary()
let orientation: ALAssetOrientation = ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!
library.writeImageToSavedPhotosAlbum(image.CGImage, orientation: orientation, completionBlock: nil)
和視頻:
ALAssetsLibrary().writeVideoAtPathToSavedPhotosAlbum(outputFileURL, completionBlock: {
(assetURL:NSURL!, error:NSError!) in
if error != nil{
print(error)
}
do {
try NSFileManager.defaultManager().removeItemAtURL(outputFileURL)
} catch _ {
}
if backgroundRecordId != UIBackgroundTaskInvalid {
UIApplication.sharedApplication().endBackgroundTask(backgroundRecordId)
}
})