Im using Photos framework to save and retrieve videos from the device's album.
While saving my videos, i would like to add some custom data, like: id, name, description, and so on... and to get all this data while retrieving it back from the album.
is that possible ?
The code I'm using to save the videos is:
func saveVideo(url: URL, completionHandler: @escaping (Bool, Error?) -> ()) {
if assetCollection == nil {
return // If there was an error upstream, skip the save.
}
PHPhotoLibrary.shared().performChanges({
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
let assetPlaceholder = assetChangeRequest?.placeholderForCreatedAsset
let albumChangeRequest = PHAssetCollectionChangeRequest(for: self.assetCollection)
albumChangeRequest?.addAssets([assetPlaceholder] as NSFastEnumeration)
}, completionHandler: {
saved, error in
completionHandler(saved,error)
})
}