capacitor-camera-module 0.0.53 → 0.0.55
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,37 @@ 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
|
+
}
|
|
176
|
+
|
|
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
|
+
])
|
|
172
189
|
|
|
173
|
-
|
|
174
|
-
let
|
|
190
|
+
// Preview layer
|
|
191
|
+
let previewLayer = AVCaptureVideoPreviewLayer(session: session)
|
|
192
|
+
previewLayer.videoGravity = .resizeAspectFill
|
|
193
|
+
previewLayer.frame = container.bounds
|
|
175
194
|
|
|
176
|
-
|
|
177
|
-
layer.videoGravity = .resizeAspectFill
|
|
178
|
-
layer.frame = view.bounds
|
|
195
|
+
previewView.layer.insertSublayer(previewLayer, at: 0)
|
|
179
196
|
|
|
180
|
-
|
|
181
|
-
|
|
197
|
+
if let webView = self.bridge?.webView {
|
|
198
|
+
container.bringSubviewToFront(webView)
|
|
199
|
+
}
|
|
182
200
|
|
|
183
|
-
self.previewView =
|
|
184
|
-
self.videoPreviewLayer =
|
|
201
|
+
self.previewView = previewView
|
|
202
|
+
self.videoPreviewLayer = previewLayer
|
|
185
203
|
self.captureSession = session
|
|
186
204
|
|
|
187
205
|
session.startRunning()
|
|
@@ -189,6 +207,7 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
189
207
|
}
|
|
190
208
|
}
|
|
191
209
|
|
|
210
|
+
|
|
192
211
|
@objc func stopPreview(_ call: CAPPluginCall) {
|
|
193
212
|
DispatchQueue.main.async {
|
|
194
213
|
self.captureSession?.stopRunning()
|