Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The operation could not be completed error using UIImagePickerControler

I'm using UIImagePickerController in a part of my app that allows the user to pick a video from the camera roll. The problem I'm having is that when choosing certain specific videos from the image picker view controller at runtime, I get a dialog box saying "The operation could not be completed," and the app freezes.

The error and freeze occur as soon as you click on the video you want from the Camera Roll, and before you hit the "Choose" button -- so, when the error occurs, didFinishPickingMediaWithInfo() has not yet been triggered.

The videos triggering the error are not corrupt files, as I can watch them just fine using my phone's Camera Roll app directly.

Here is the code I have in my project to set up the UIImagePickerViewController:

videoViewController = UIImagePickerController()
videoViewController.delegate = self
videoViewController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
videoViewController.mediaTypes = [kUTTypeMovie as String] 
videoViewController.allowsEditing = false
videoViewController.modalPresentationStyle = .CurrentContext 

The two files that are triggering this error do have one thing in common -- they both were texted to me from someone else's phone. But if they are not corrupt, what could possibly be going on?

like image 216
ClayJ Avatar asked Mar 11 '17 01:03

ClayJ


1 Answers

The answer to the question is that the video files that are triggering the error are all of type .3gp.

It turns out that knowledge of that fact is useless if I still want to use UIPickerImageController to let the user pick a video. There's no way to control which video file types show up in UIPickerImageController, nor is there any way to add to Apple's code in order to convert a .3gp video to a different format in the time between when the user clicks on it in the UIPickerImageController and the time when the crash occurs.

like image 143
ClayJ Avatar answered Nov 02 '22 01:11

ClayJ