我无法播放来自AVCaptureFileOutputDelegate的视频。我想我在这里错过了一些我的代码。
func recordVideo() {
let recordingDelegate: AVCaptureFileOutputRecordingDelegate? = self
self.session!.addOutput(videoFileOutput)
self.session!.sessionPreset = AVCaptureSessionPresetHigh
let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let filePath = documentsURL.appendingPathComponent("temp")
videoFileOutput.startRecording(toOutputFileURL: filePath, recordingDelegate: recordingDelegate)
}
和代表。
func capture(_ captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAt outputFileURL: URL!, fromConnections connections: [Any]!, error: Error!) {
if error == nil {
print("Play: \(outputFileURL!)")
self.playVideo(path: outputFileURL!)
} else {
print(error)
}
return
}
但视频没有播放。我想我错过了文件名或其他东西。请帮忙。谢谢!