I'm working on a project which involves video capture. I essentially want to capture video programatically, meaning that I don't want any camera or anything to pop up; I just want video to be recorded between the times two buttons are pressed.
I defined the imagepicker and started video capture when a button is pressed:
if (UIImagePickerController.isSourceTypeAvailable(.camera)) {
imagePicker.sourceType = .camera
imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.front
imagePicker.allowsEditing = false
imagePicker.delegate = self
}
imagePicker.startVideoCapture()
print("Capture started")
later, I stopped video capture:
imagePicker.stopVideoCapture()
print("capture over")
I know this should be calling my method:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
print("captured")
}
For some reason my video doesn't start recording, as the boolean imagepicker.startvideocapture returns false. I'm completely stuck on why this is happening; could someone please provide some suggestions?