Search code examples
iosobjective-cuikitalassetslibrary

UIVideoAtPathIsCompatibleWithSavedPhotosAlbum not finding the file


I am trying to cleanup the deprecated warnings and having trouble with migrating from

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if([library videoAtPathIsCompatibleWithSavedPhotosAlbum:srcURL]) {
    ...

to

if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(srcURL.absoluteString)) {
    ...

with both the same

NSURL *srcURL = ...

The first call works fine, but the second one gives me the following output in the console and returns false.

Video file:///var/mobile/Containers/Data/Application/8149A5B8-11EA-41E6-B1A7-2CCAABDE5E35/tmp/tempAudio.mov cannot be saved to the saved photos album: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." .......

Any ideas?


Solution

  • Replace srcURL.absoluteString with srcURL.path.

    UIVideoAtPathIsCompatibleWithSavedPhotosAlbum() expects a path, so the parameter value should not include a scheme like file://.