0

Recently we have updated iOS 13. Earlier to the update our app was able to pick videos/media from Gallery. But lately after new update, the app picks the video from gallery but once it is uploaded, the uploaded content is shown as 0 bytes. Guessing that OS is not giving access to Gallery from our app.

In iOS 12 and prior versions we didn't see this issue. Gallery was working fine with our App.

Below delegate method returns different URLs in iOS 13 and earlier iOS versions.

- (void)videoPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
  NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];}

I am returning Video URL path from the UIImagePickerController.

iOS 13 returns below value
file:///private/var/mobile/Containers/Data/PluginKitPlugin/36B89CF8-26FC-44BA-AFE1-D689DC04AF44/tmp/trim.400D33F1-BA28-42C8-B6B7-5CEC26656917.MOV

Earlier iOS versions returns below value file:///private/var/mobile/Containers/Data/Application/7BFD7CEC-E383-4C63-8DF8-A0830EE948AC/tmp/36346EAD-AADC-4A9A-9DEE-416A2DE0BE71.MOV

Note: When the video recorded in camera directly from app is uploaded. It doesn't throw us any issues. It is when the video picked from Gallery then the app behaves differently.

Please share your suggessions.

Thanks in advance.

2 Answers2

0

I had a similar issue. I think the solution is to copy the video to a temporary location that your App has access to.

The answer from another question is here.

Bumbleparrot
  • 323
  • 1
  • 8
-1

Solution for above issue: in iOS13 after dismiss the video album, video URL is getting invalide. For this we need to change URL Directory Path.

NSURL *videoURL1 = [info objectForKey:UIImagePickerControllerMediaURL];

NSMutableData *imageData = [NSMutableData dataWithContentsOfURL:videoURL1];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *videoPath =[documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%u.MOV",arc4random() % 99999]]];

BOOL success = [imageData writeToFile:videoPath atomically:NO];

NSURL *videoURL = [NSURL fileURLWithPath:videoPath];
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Reading an entire video into memory is completely wrong. If you want to display the video immediately, do so, without keeping the URL. If you want to maintain a reference to the video the user picked to use the video later, use the PHAsset. If you want to copy the video to another folder use the FileManager. – matt Oct 15 '19 at 09:54