Post

Replies

Boosts

Views

Activity

Cannot use PHPickerViewController to load mpeg-4 video
I'm trying to use PHPickerViewController to load video from user's photo library. Here is my code: func videoSelectorAskForSelectFromAlbum(_ selector: VideoSelector) { var config = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) config.selectionLimit = 1 config.filter = .videos config.preferredAssetRepresentationMode = .compatible let picker = PHPickerViewController(configuration: config) picker.delegate = self present(picker, animated: true) } func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { guard results.count == 1 else { picker.dismiss(animated: true)         return     }     let provider = results[0].itemProvider     guard let identifier = provider.registeredTypeIdentifiers.first, provider.hasItemConformingToTypeIdentifier(identifier) else {         picker.dismiss(animated: true)         return     }     picker.dismiss(animated: true) { [self] in // provider.loadFileRepresentation cause error         videoLoadingProgress = provider.loadFileRepresentation(forTypeIdentifier: identifier) { url, err in print(url)         }     } } Everything is ok on Simulator, however, when I run it on a real iPad and select a video from photo library, it crashed with errors: [claims] 2F5DAD68-8F99-4A84-8BF2-3BF0AEB0027F grantAccessClaim reply is an error: Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x282ed17d0 {Error Domain=PFPAssetRequestErrorDomain Code=0 "The operation couldn’t be completed. (PFPAssetRequestErrorDomain error 0.)" UserInfo={NSLocalizedDescription=The operation couldn’t be completed. (PFPAssetRequestErrorDomain error 0.)}}} Error copying file type public.mpeg-4. Error: Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.mpeg-4" UserInfo={NSLocalizedDescription=Cannot load representation of type public.mpeg-4, NSUnderlyingError=0x282ed2dc0 {Error Domain=NSCocoaErrorDomain Code=4101 "Couldn’t communicate with a helper application." UserInfo={NSUnderlyingError=0x282ed17d0 {Error Domain=PFPAssetRequestErrorDomain Code=0 "The operation couldn’t be completed. (PFPAssetRequestErrorDomain error 0.)" UserInfo={NSLocalizedDescription=The operation couldn’t be completed. (PFPAssetRequestErrorDomain error 0.)}}}}} I checked the info of the video file, its extension is .mp4 which shows "public.mpeg-4" in code. The strange thing is, when I try to load a .mov file which shows "com.apple.quicktime-movie" in code, it runs well without error! I'm confused and struggling with it, Is that a bug? or I'm using PHPickerViewController in wrong way?
2
1
1.5k
Jan ’23