[英]Trigger iphone video recording after x seconds
In a swift app, I want to start recording a video with the camera, after a 10 seconds wait. 在一个快速的应用程序中,我想在等待10秒后开始用相机录制视频。
Once the 10 seconds wait is over, this function is called: 一旦10秒等待结束,就会调用此函数:
func startRecording() {
// trigger video recording
}
So far, when a user clicked on a "Record video button", it displayed the camera interface, and the user then had to click on the built-in record button: 到目前为止,当用户点击“录制视频按钮”时,它会显示相机界面,然后用户必须单击内置录制按钮:
@IBAction func recordVideo(sender: AnyObject) {
if (UIImagePickerController.isSourceTypeAvailable(.Camera)) {
if UIImagePickerController.availableCaptureModesForCameraDevice(.Rear) != nil {
imagePicker.sourceType = .Camera
imagePicker.mediaTypes = [kUTTypeMovie as String]
imagePicker.allowsEditing = false
imagePicker.delegate = self
locationManager.startUpdatingLocation()
print(locationManager.location)
presentViewController(imagePicker, animated: true, completion: {})
} else {
postAlert("Rear camera doesn't exist", message: "Application cannot access the camera.")
}
} else {
postAlert("Camera inaccessible", message: "Application cannot access the camera.")
}
}
What I'm trying to do, is trigger automatically the recording, 10 seconds after the "Record video button" was hit. 我正在尝试做的是,在“录制视频按钮”被击中10秒后自动触发录制。
I couldn't find information on how to "trigger" the recording. 我找不到有关如何“触发”录音的信息。 Is there a way of doing this ?
有办法做到这一点吗?
Thanks for your help 谢谢你的帮助
你可以在呈现UIImagePickerController
之后添加它:
imagePicker.performSelector(#selector(UIImagePickerController.startVideoCapture), withObject: nil, afterDelay: 10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.