Following code works good when capturing photo using camera, but app crashes when user taps on video.
let imagePicker = UIImagePickerController()
imagePicker.modalPresentationStyle = .currentContext
imagePicker.delegate = self
if let _ = UIImagePickerController.availableMediaTypes(for: .camera) {
imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .camera)!
if UIImagePickerController.isSourceTypeAvailable(.camera) {
imagePicker.sourceType = .camera
present(imagePicker, animated: true, completion: nil)
}
}