[英]Type does not conform to protocol 'AVCaptureFileOutputRecordingDelegate'
I am trying to use AVCaptureMovieFileOutput.startRecordingToOutputFileURL to record audio to a file, and the syntax for the function asks for a variable of type "AVCaptureFileOutputRecordingDelegate." 我正在尝试使用AVCaptureMovieFileOutput.startRecordingToOutputFileURL将音频录制到文件中,并且该函数的语法要求输入“AVCaptureFileOutputRecordingDelegate”类型的变量。 All of the help I've seen from this site says that you need to make a class an extension of AVCaptureFileOutputRecordingDelegate, and NSObject.
我从这个站点看到的所有帮助都表明你需要使一个类成为AVCaptureFileOutputRecordingDelegate和NSObject的扩展。
Problem is, I always get the error: Type 'AVRecordDevices' does not conform to protocol 'AVCaptureFileOutputRecordingDelegate' 问题是,我总是得到错误: 类型'AVRecordDevices'不符合协议'AVCaptureFileOutputRecordingDelegate'
How do I fix it? 我如何解决它?
PS I am developing for OS X if that means anything in this situation. PS我正在为OS X开发,如果这意味着在这种情况下。
Updated answer for Swift 4.0: 更新了Swift 4.0的答案:
Apple documentation . Apple文档 。
import AVFoundation
extension ViewController: AVCaptureFileOutputRecordingDelegate {
func fileOutput(_ output: AVCaptureFileOutput,
didFinishRecordingTo outputFileURL: URL,
from connections: [AVCaptureConnection],
error: Error?) {
// Handle output
}
}
Original answer for Swift 3.0: Swift 3.0的原始答案:
func capture(_ captureOutput: AVCaptureFileOutput!,
didFinishRecordingToOutputFileAt outputFileURL: URL!,
fromConnections connections: [Any]!,
error: Error!) { }
It means that you don't have the proper methods implemented in your view controller: 这意味着您没有在视图控制器中实现正确的方法:
By taking a closer look at apple´s docs you'll see that is mandatory to have at least this: 通过仔细研究苹果的文档,你会发现必须至少有这样的:
func captureOutput(captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAtURL outputFileURL: NSURL!, fromConnections connections: [AnyObject]!, error: NSError!)
{
}
https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureFileOutputRecordingDelegate_Protocol/ https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVCaptureFileOutputRecordingDelegate_Protocol/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.