I'm working on a project which involves video capture. I essentially want to capture video programatically.
I defined the imagepicker and started video capture:
if (UIImagePickerController.isSourceTypeAvailable(.camera)) {
imagePicker.sourceType = .camera
imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.front
imagePicker.allowsEditing = false
imagePicker.delegate = self
//present(imagePicker, animated: true, completion: {})
}
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")
if let pickedvideo:NSURL = (info[UIImagePickerControllerMediaURL] as! NSURL) {
let selectorToCall = Selector("videoWasSavedSuccessfully.didFinishSavingWithError:context:")
UISaveVideoAtPathToSavedPhotosAlbum(pickedvideo.relativePath!, self, selectorToCall, nil)
let videoasset = (AVAsset(url: pickedvideo as URL))
let playeritem = AVPlayerItem(asset: videoasset)
let player = AVPlayer(playerItem: playeritem)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player?.play()
}
}
}
but the "captured" doesn't get printed, even though I know I'm starting and stopping the recording, as "Capture started" and "Capture over" are printed. I'm not sure why the method isn't being called. Any suggestions?