简体   繁体   English

x秒后触发iphone视频录制

[英]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.

相关问题 如何在 swiftUI 中 x 秒后触发操作 - How to trigger action after x seconds in swiftUI 录制后临时目录中的 AVPlayer 视频在几秒钟后停止播放 - AVPlayer video from temporary directory after recording stops playing after few seconds Swift iPad - AVAssetWriter AVCapture session recording video gets a green video after few seconds in iPad iOS12.4 - Swift iPad - AVAssetWriter AVCapture session recording video gets a green video after few seconds in iPad iOS12.4 Swift / iOS:仅捕获视频录制的前10秒 - Swift/iOS: Capture only the previous 10 seconds of a video recording UIImagePickerController视频录制在延迟或无法正常工作后开始 - UIImagePickerController video recording starts after delay or not working 停止录制视频后调用代表方法 - Called Delegate Method after Stopping Recording Video X秒后如何更改NSTimer的NSTimeInterval? - How to change the NSTimeInterval of an NSTimer after X seconds? 迅速x秒后移除标签 - Remove label after x seconds in swift X 秒后关闭模式 ViewController - Dismiss a modal ViewController after X seconds RxSwift-X秒钟未收到项目后发出 - RxSwift - Emit after not receiving items for X seconds
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM