I use loadFileRepresentation to register video URL. After that, loadItem will take less time to see the video from the picker. But after upgrade Iphone to 16.6, this func can not work. Have any change or dev team removed loadItem
it? Here is my sample code:
provider.loadItem(forTypeIdentifier: "public.movie", options: nil) { url, error in
guard let url = url as? URL else {
return
}
self.parent.selectedVideoURL = url
// Check cached, if loadFileRepresentation before use url from loadItem more faster
let storage = LocalStorageHelper()
if storage.checkStringExistStorage(MEDIA_PICKER_STORAGE_NAMESPACE, url.relativeString) {
DispatchQueue.main.async {
self.parent.presentationMode.wrappedValue.dismiss()
self.parent.videoURL = url
}
} else {
provider.loadFileRepresentation(forTypeIdentifier: "public.movie") { urlResult, error in
DispatchQueue.main.async {
self.parent.presentationMode.wrappedValue.dismiss()
}
if let error = error {
// Handle errors loading video
LOGGING.error("Error loading video: \(error.localizedDescription)")
return
}
guard let urlFile = urlResult else {return}
// create a new filename
let fileName = "\(Int(Date().timeIntervalSince1970)).\(urlFile.pathExtension)"
// create new URL
let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName)
// copy item to APP Storage
try? FileManager.default.copyItem(at: urlFile, to: newUrl)
DispatchQueue.main.async {
storage.saveStringToStorage(MEDIA_PICKER_STORAGE_NAMESPACE, url.relativeString)
self.parent.videoURL = URL(string: newUrl.absoluteString)
}
}
}
}