gpt4 book ai didi

swift - x 秒后触发 iphone 视频录制

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:44 26 4
gpt4 key购买 nike

在一个 swift 应用程序中,我想在等待 10 秒后开始用相机录制视频。

一旦 10 秒等待结束,将调用此函数:

func startRecording() {
// trigger video recording
}

到目前为止,当用户点击“录制视频按钮”时,它会显示相机界面,然后用户必须点击内置的录制按钮:

@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.")
}
}

我想要做的是在点击“录制视频按钮”10 秒后自动触发录制。

我找不到有关如何“触发”录音的信息。有办法做到这一点吗?

谢谢你的帮助

最佳答案

您可以在呈现 UIImagePickerController 之后添加:

imagePicker.performSelector(#selector(UIImagePickerController.startVideoCapture), withObject: nil, afterDelay: 10)

关于swift - x 秒后触发 iphone 视频录制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39943385/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com