Hello,
thanks for the help. I read those documentation pages too but I couldn't understand how to implement the solution.
I will show my code with the errors and I hope you will can help me better.
I am developing a video capture app for MacOS using SwiftUI.
Here is my custom view to show the preview from the camera.
Take a look to the function setupBraille().
When I try to compile the project XCode gives me these errors:
Value of type 'CameraPreviewLayout' has no member 'accessibilityBrailleMapRenderer'
Unable to infer type of a closure parameter 'map' in the current context
Here is my code:
import SwiftUI
import AVFoundation
import Accessibility
struct CameraView: NSViewRepresentable {
let captureSession: AVCaptureSession
init(captureSession: AVCaptureSession) {
self.captureSession = captureSession
}
func makeNSView(context: Context) -> CameraPreviewLayout {
return CameraPreviewLayout(captureSession: captureSession)
}
func updateNSView(_ nsView: CameraPreviewLayout, context: Context) { }
}
class CameraPreviewLayout: NSView, AXBrailleMapRenderer {
var previewLayer: AVCaptureVideoPreviewLayer?
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(captureSession: AVCaptureSession) {
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
super.init(frame: .zero)
setupLayer()
setupBraille()
}
func setupLayer() {
previewLayer?.frame = self.frame
previewLayer?.contentsGravity = .resizeAspectFill
previewLayer?.videoGravity = .resizeAspectFill
previewLayer?.connection?.automaticallyAdjustsVideoMirroring = false
previewLayer?.connection?.isVideoMirrored = true
layer = previewLayer
}
func setupBraille() {
self.accessibilityBrailleMapRenderer = { map in
// code to manage the braille display
}
}
}