Post

Replies

Boosts

Views

Activity

How do you properly get Video Data from PHPicker?
Hello, I understand that PHPicker works by overlaying the users' library so that the developer doesn't need to ask for permission to get Images or Videos. The demo video very clearly showed how to get access to Images by getting UIImage using the canLoadObject(ofClass: ) method. However, there is no such call for video assets. I even tested all of the objects that are listed as implementers of the NSItemProviderReading protocol, and none of them worked, including the AVURLAsset, and AVFragmentedAsset which seemed like the most likely candidates. In the demo video it mentions that you can also get access to video data but there is no clear way to do that. I have found a few solutions floating around online that show them using the loadItem(forType: ) function as follows. itemProvider.loadItem(forTypeIdentifier: "com.apple.quicktime-movie", options: nil) Then in the response they can get a URL and use the video that way. However, when I use that method to get the URL I then try and get the video data using Data(contentsOf: URL) I'm getting the following error. Error Domain=NSCocoaErrorDomain Code=260 "The file “version=1&uuid=FAKEGUID-FAKE-GUID-FAKE-GUIDFAKEGUID&mode=compatible.mov” couldn’t be opened because there is no such file." (Note: I replaced the actual guid if you couldn't tell) Also, a side note, I don't really like getting the Item from the typeIdentifier because it requires me to check for other cases as well, .mp4 vs .mov extensions for example. I'm able to get the video data that I need by using the PHAsset fetchAssetsWithLocalIdentifiers route, but I would prefer to avoid that route because it involves getting permissions and dealing with limited libraries. I don't think that my use case requires me to get the PHAsset but I do need access to the video Data. Is there a straightforward way to get video data using only the PHPiker that I'm missing? Or is it necessary to use PhotoKit to get that data? Thank you in advance for the help!
1
0
2.6k
Sep ’20