4

My app provides a video upload function. But after selecting the video, UIImagePickerController will perform video compression. At this time, clicking the Cancel button will not interrupt the compression process. Is there a way to solve this problem? Reference Image: https://i.stack.imgur.com/mBSAv.png

system is iOS 12.1

 let vc = UIImagePickerController()
 vc.sourceType = .photoLibrary
 vc.mediaTypes = [kUTTypeMovie as String]
 vc.delegate = self
 navigationController?.present(vc, animated: true, completion: nil)
//when compressing video left button is not responding
MS_iOS
  • 401
  • 1
  • 5
  • 13
tanquwell
  • 53
  • 6

1 Answers1

0

You can't interrupt the systems UIImagePickerController video compression.

What you can do if you need this functionality is initialize the UIImagePickerController with passthrough preset like this:

if (@available(iOS 11.0, *))
    picker.videoExportPreset = AVAssetExportPresetPassthrough;

Then you can fully manage compression with something like SDAVAssetExportSession (that is a more feature-complete version of systems AVAssetExportSession) and a modal view with a progress indicator and a cancel button that call cancelExport of your exportSession instance.

Shebuka
  • 3,148
  • 1
  • 26
  • 43