@capgo/camera-preview 6.5.26 → 6.5.28
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.
|
@@ -1118,8 +1118,6 @@ public class CameraActivity extends Fragment {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
|
-
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
|
|
1122
|
-
mRecorder.setProfile(profile);
|
|
1123
1121
|
if (disableAudio) {
|
|
1124
1122
|
mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
|
|
1125
1123
|
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
|
|
@@ -1127,6 +1125,8 @@ public class CameraActivity extends Fragment {
|
|
|
1127
1125
|
mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
|
|
1128
1126
|
}
|
|
1129
1127
|
|
|
1128
|
+
mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
|
|
1129
|
+
mRecorder.setProfile(profile);
|
|
1130
1130
|
mRecorder.setOutputFile(filePath);
|
|
1131
1131
|
mRecorder.setOrientationHint(mOrientationHint);
|
|
1132
1132
|
mRecorder.setMaxDuration(maxDuration);
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -33,7 +33,10 @@ extension UIWindow {
|
|
|
33
33
|
*/
|
|
34
34
|
@objc(CameraPreview)
|
|
35
35
|
public class CameraPreview: CAPPlugin {
|
|
36
|
-
|
|
36
|
+
// Camera state tracking
|
|
37
|
+
private var isInitializing: Bool = false
|
|
38
|
+
private var isInitialized: Bool = false
|
|
39
|
+
|
|
37
40
|
var previewView: UIView!
|
|
38
41
|
var cameraPosition = String()
|
|
39
42
|
let cameraController = CameraController()
|
|
@@ -161,6 +164,16 @@ public class CameraPreview: CAPPlugin {
|
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
@objc func start(_ call: CAPPluginCall) {
|
|
167
|
+
if self.isInitializing {
|
|
168
|
+
call.reject("camera initialization in progress")
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
if self.isInitialized {
|
|
172
|
+
call.reject("camera already started")
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
self.isInitializing = true
|
|
176
|
+
|
|
164
177
|
self.cameraPosition = call.getString("position") ?? "rear"
|
|
165
178
|
let cameraMode = call.getBool("cameraMode") ?? false
|
|
166
179
|
self.highResolutionOutput = call.getBool("enableHighResolution") ?? false
|
|
@@ -222,6 +235,8 @@ public class CameraPreview: CAPPlugin {
|
|
|
222
235
|
NotificationCenter.default.addObserver(self, selector: #selector(CameraPreview.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
|
223
236
|
}
|
|
224
237
|
|
|
238
|
+
self.isInitializing = false
|
|
239
|
+
self.isInitialized = true
|
|
225
240
|
call.resolve()
|
|
226
241
|
|
|
227
242
|
}
|
|
@@ -242,10 +257,21 @@ public class CameraPreview: CAPPlugin {
|
|
|
242
257
|
|
|
243
258
|
@objc func stop(_ call: CAPPluginCall) {
|
|
244
259
|
DispatchQueue.main.async {
|
|
260
|
+
if self.isInitializing {
|
|
261
|
+
call.reject("cannot stop camera while initialization is in progress")
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
if !self.isInitialized {
|
|
265
|
+
call.reject("camera not initialized")
|
|
266
|
+
return
|
|
267
|
+
}
|
|
245
268
|
if self.cameraController.captureSession?.isRunning ?? false {
|
|
246
269
|
self.cameraController.captureSession?.stopRunning()
|
|
247
|
-
self.previewView
|
|
270
|
+
if let previewView = self.previewView {
|
|
271
|
+
previewView.removeFromSuperview()
|
|
272
|
+
}
|
|
248
273
|
self.webView?.isOpaque = true
|
|
274
|
+
self.isInitialized = false
|
|
249
275
|
call.resolve()
|
|
250
276
|
} else {
|
|
251
277
|
call.reject("camera already stopped")
|