capacitor-camera-module 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -169,19 +169,33 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
169
169
|
session.addOutput(self.photoOutput)
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
guard let container = self.bridge?.viewController?.view else {
|
|
173
|
+
call.reject("No container view")
|
|
174
|
+
return
|
|
175
|
+
}
|
|
172
176
|
|
|
173
|
-
|
|
174
|
-
let
|
|
177
|
+
// Preview view
|
|
178
|
+
let previewView = UIView()
|
|
179
|
+
previewView.translatesAutoresizingMaskIntoConstraints = false
|
|
180
|
+
previewView.backgroundColor = .black
|
|
181
|
+
container.addSubview(previewView)
|
|
182
|
+
|
|
183
|
+
NSLayoutConstraint.activate([
|
|
184
|
+
previewView.topAnchor.constraint(equalTo: container.topAnchor),
|
|
185
|
+
previewView.bottomAnchor.constraint(equalTo: container.bottomAnchor),
|
|
186
|
+
previewView.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
187
|
+
previewView.trailingAnchor.constraint(equalTo: container.trailingAnchor)
|
|
188
|
+
])
|
|
175
189
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
190
|
+
// Preview layer
|
|
191
|
+
let previewLayer = AVCaptureVideoPreviewLayer(session: session)
|
|
192
|
+
previewLayer.videoGravity = .resizeAspectFill
|
|
193
|
+
previewLayer.frame = container.bounds
|
|
179
194
|
|
|
180
|
-
|
|
181
|
-
self.bridge?.viewController?.view.insertSubview(view, at: 0)
|
|
195
|
+
previewView.layer.insertSublayer(previewLayer, at: 0)
|
|
182
196
|
|
|
183
|
-
self.previewView =
|
|
184
|
-
self.videoPreviewLayer =
|
|
197
|
+
self.previewView = previewView
|
|
198
|
+
self.videoPreviewLayer = previewLayer
|
|
185
199
|
self.captureSession = session
|
|
186
200
|
|
|
187
201
|
session.startRunning()
|
|
@@ -189,6 +203,7 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
189
203
|
}
|
|
190
204
|
}
|
|
191
205
|
|
|
206
|
+
|
|
192
207
|
@objc func stopPreview(_ call: CAPPluginCall) {
|
|
193
208
|
DispatchQueue.main.async {
|
|
194
209
|
self.captureSession?.stopRunning()
|