capacitor-camera-module 0.0.60 → 0.0.62
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.
|
@@ -157,7 +157,6 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
let session = AVCaptureSession()
|
|
160
|
-
session.sessionPreset = .photo
|
|
161
160
|
|
|
162
161
|
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
|
|
163
162
|
let input = try? AVCaptureDeviceInput(device: device) else {
|
|
@@ -178,50 +177,68 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
178
177
|
return
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
//
|
|
180
|
+
// 1. Cambia isUserInteractionEnabled a true
|
|
182
181
|
let previewView = UIView()
|
|
183
|
-
|
|
184
|
-
// 🔑 MUY IMPORTANTE
|
|
185
|
-
previewView.isUserInteractionEnabled = false
|
|
186
182
|
previewView.translatesAutoresizingMaskIntoConstraints = false
|
|
187
183
|
previewView.backgroundColor = .black
|
|
184
|
+
previewView.isUserInteractionEnabled = true // CAMBIO IMPORTANTE
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
previewView.backgroundColor = .red // Para ver si la vista se muestra
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
// Agrega esto después de crear la vista
|
|
191
|
+
print("PreviewView frame: \(previewView.frame)")
|
|
192
|
+
print("Superview: \(previewView.superview)")
|
|
188
193
|
|
|
189
194
|
guard let webView = self.bridge?.webView else {
|
|
190
195
|
call.reject("No webView")
|
|
191
196
|
return
|
|
192
197
|
}
|
|
193
198
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
previewView.layer.zPosition = 0
|
|
197
|
-
|
|
199
|
+
// 2. Inserta la previewView sobre el webView temporalmente para debug
|
|
200
|
+
container.addSubview(previewView)
|
|
198
201
|
|
|
202
|
+
// 3. Configura constraints
|
|
203
|
+
let safeArea = container.safeAreaLayoutGuide
|
|
199
204
|
NSLayoutConstraint.activate([
|
|
200
205
|
previewView.topAnchor.constraint(equalTo: container.topAnchor),
|
|
201
|
-
previewView.bottomAnchor.constraint(equalTo:
|
|
206
|
+
previewView.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -180),
|
|
202
207
|
previewView.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
203
208
|
previewView.trailingAnchor.constraint(equalTo: container.trailingAnchor)
|
|
204
209
|
])
|
|
205
210
|
|
|
211
|
+
// 4. FORZA el layout inmediatamente
|
|
212
|
+
container.layoutIfNeeded()
|
|
206
213
|
|
|
207
|
-
//
|
|
214
|
+
// 5. Crea el previewLayer después de tener el tamaño correcto
|
|
208
215
|
let previewLayer = AVCaptureVideoPreviewLayer(session: session)
|
|
209
216
|
previewLayer.videoGravity = .resizeAspectFill
|
|
210
|
-
|
|
211
|
-
previewView.layoutIfNeeded()
|
|
212
217
|
previewLayer.frame = previewView.bounds
|
|
218
|
+
previewLayer.masksToBounds = true
|
|
213
219
|
|
|
214
220
|
previewView.layer.insertSublayer(previewLayer, at: 0)
|
|
215
221
|
|
|
216
|
-
|
|
217
|
-
|
|
222
|
+
// 6. Guarda referencias
|
|
218
223
|
self.previewView = previewView
|
|
219
224
|
self.videoPreviewLayer = previewLayer
|
|
220
225
|
self.captureSession = session
|
|
221
226
|
|
|
227
|
+
// 7. Configura la sesión ANTES de iniciarla
|
|
228
|
+
session.sessionPreset = .photo
|
|
229
|
+
|
|
230
|
+
// 8. Inicia la sesión en background
|
|
222
231
|
DispatchQueue.global(qos: .userInitiated).async {
|
|
223
232
|
session.startRunning()
|
|
233
|
+
|
|
234
|
+
// 9. Vuelve al main thread para verificar que se esté mostrando
|
|
235
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
236
|
+
print("Preview frame: \(previewView.frame)")
|
|
237
|
+
print("Preview layer frame: \(previewLayer.frame)")
|
|
238
|
+
print("Preview visible: \(previewView.window != nil)")
|
|
239
|
+
}
|
|
224
240
|
}
|
|
241
|
+
|
|
225
242
|
call.resolve()
|
|
226
243
|
}
|
|
227
244
|
}
|
|
@@ -233,7 +250,10 @@ public class CameraModulePlugin: CAPPlugin,CAPBridgedPlugin,AVCaptureVideoDataOu
|
|
|
233
250
|
self.captureSession = nil
|
|
234
251
|
self.videoPreviewLayer?.removeFromSuperlayer()
|
|
235
252
|
self.previewView?.removeFromSuperview()
|
|
253
|
+
self.videoPreviewLayer?.session = nil
|
|
254
|
+
|
|
236
255
|
self.videoPreviewLayer = nil
|
|
256
|
+
|
|
237
257
|
self.previewView = nil
|
|
238
258
|
call.resolve()
|
|
239
259
|
}
|