Pick video with UIpickerViewController with maximum length of 10 seconds - swift - programmatically

518 Views Asked by At

I'm using UIPickerViewController to select images and video from the device camera roll. When I select videos I would like to pick a video of maximum 10 seconds, and if longer to give the possibility for the user to trim it.

Until now I've searched online and did this, but it doesn't seem to work:

let imagePickerController = UIImagePickerController()
    imagePickerController.videoMaximumDuration = 10.0
    imagePickerController.mediaTypes = ["public.image", "public.movie"]
    imagePickerController.delegate = self
    self.present(imagePickerController, animated: true, completion: nil)
1

There are 1 best solutions below

0
StackGU On

I found the solution, everything you need to do is to add this line before presenting:

imagePickerController.allowsEditing = true