作者:ngzhaicai9672364 | 来源:互联网 | 2022-12-26 14:10
这是我的代码设置一个简单的相机应用程序
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let deviceSession = AVCaptureDeviceDiscoverySession(deviceTypes: [.builtInDualCamera, .builtInTelephotoCamera, .builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: .unspecified)
for device in (deviceSession?.devices)!{
if device.position == AVCaptureDevicePosition.front {
do {
currentDevice = device
let input = try AVCaptureDeviceInput(device: device)
if captureSession.canAddInput(input){
captureSession.addInput(input)
if captureSession.canAddOutput(photoOutput){
captureSession.addOutput(photoOutput)
}
if captureSession.canAddOutput(videoOutput){
captureSession.addOutput(videoOutput)
videoOutput.connection(withMediaType: AVMediaTypeVideo).isVideoMirrored = true
}
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
previewLayer.connection.videoOrientation = .portrait //Change orientation
cameraView.layer.addSublayer(previewLayer)
cameraView.addSubview(takePictureButton)
cameraView.addSubview(takeVideoButton)
cameraView.addSubview(saveVideoButton)
previewLayer.position = CGPoint(x: self.view.center.x, y: self.view.center.y)
previewLayer.bounds = CGRect(x: 100, y: 150, width: self.view.frame.width, height: self.view.frame.height)
}
captureSession.startRunning()
} catch let avError {
print(avError)
}
}
}
}
这工作正常,但在调试窗口中抛出此消息
2018-02-26 20:12:27.699481-0800 FACS[1063:425226] [] <<<<
AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>>
-[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl
outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device
discovery mode to DiscoveryMode_None (client: FACS)
2018-02-26 20:12:27.774719-0800 FACS[1063:425226] [framework]
CUICatalog: Invalid asset name supplied: '(null)'
奇怪的是,当我尝试清理上面的代码时,它仍然有效但现在速度要慢得多(通过清理我的意思是把东西放在辅助函数中).通过查看相关帖子,
从URL播放音频给我这个日志错误并卡住了.(Swift)
AVPlayer无法在iOS 11中播放
我唯一可以推断的是它有与IOS 11相关的东西.如何解决这个错误?