我正在尝试向我的应用程序添加摄像头功能,但是这些消息一直显示在屏幕上,因此我无法为其找到解决方案。有什么可以代替的例子吗?
func setupInputOutput(){
do {
let captureDeviceInput = try AVCaptureDeviceInput(device: currentCamera!);captureSession.addInput(captureDeviceInput)
photoOutput?.setPreparedPhotoSettingsArray([AVCapturePhotoSettings(format:[AVVideoCodecKey: AVVideoCodecType.jpeg])], completionHandler: nil)
} catch {print(error)
答案 0 :(得分:0)
模拟器没有您需要在真实设备中运行的视频输入
func setupInputOutput() {
do {
guard let currentCamera = AVCaptureDevice.default(for: AVMediaType.video) else { return }
let captureDeviceInput = try AVCaptureDeviceInput(device: currentCamera);captureSession.addInput(captureDeviceInput)
photoOutput?.setPreparedPhotoSettingsArray([AVCapturePhotoSettings(format:[AVVideoCodecKey: AVVideoCodecType.jpeg])], completionHandler: nil)
} catch {
print(error)
}
}