我创建了一个到目前为止完美运行的自定义相机。我可以录制视频并停止录制,没有错误或错误。我想要添加到此相机的功能是暂停录制的功能。
经过大量的在线研究后,我发现解决方案是在点击暂停按钮时实际停止录制,并在单击恢复按钮时开始另一次录制。之后,您应该将视频合并在一起。
我不确定如何合并视频,我在线看了很多东西,但却找不到解决方案。
谢谢!
这是我的录制按钮功能
@IBAction func recordVideoButtonPressed(sender:AnyObject) {
if self.movieFileOutput.isRecording {
isRecording = false
self.movieFileOutput.stopRecording()
} else {
isRecording = true
self.movieFileOutput.connection(withMediaType: AVMediaTypeVideo).videoOrientation = self.videoOrientation()
self.movieFileOutput.maxRecordedDuration = self.maxRecordedDuration()
self.movieFileOutput.startRecording(toOutputFileURL: URL(fileURLWithPath: self.videoFileLocation()), recordingDelegate: self)
}
self.updateRecordButtonTitle()
}
这是我的暂停按钮功能
func pauseVideo() {
if isRecording {
if isPaused == false {
isPaused = true
recordButton.isEnabled = false
recordButton.backgroundColor = UIColor.wetAsphalt
recordButton.setTitle("Paused", for: .normal)
} else {
isPaused = false
recordButton.isEnabled = true
recordButton.backgroundColor = UIColor.red
updateRecordButtonTitle()
}
} else {
return
}
}