node-red-node-ui-webcam
Advanced tools
+1
-1
| { | ||
| "name": "node-red-node-ui-webcam", | ||
| "version": "0.4.0", | ||
| "version": "0.5.0", | ||
| "description": "A Node-RED ui node to capture images from a webcam.", | ||
@@ -5,0 +5,0 @@ "author": "Nick O'Leary", |
+19
-10
@@ -386,12 +386,21 @@ /** | ||
| if (msg.camera !== undefined) { | ||
| if (!isNaN(parseInt(msg.camera))) { | ||
| var c = parseInt(msg.camera); | ||
| if (c >= 0 || c < 16) { | ||
| oldActiveCamera = activeCamera; | ||
| $scope.disableCamera(); | ||
| activeCamera = null; | ||
| window.localStorage.setItem("node-red-node-ui-webcam-activeCam",c); | ||
| if (active !== false) { | ||
| $scope.enableCamera(); | ||
| } | ||
| let c = parseInt(msg.camera); | ||
| if (!isNaN(c)) { | ||
| // Check if cameras array is populated | ||
| if ($scope.data.cameras && $scope.data.cameras.length > c) { | ||
| $scope.changeCamera(c); | ||
| } else { | ||
| // Enumerate devices first, then change camera | ||
| navigator.mediaDevices.enumerateDevices().then(function(devices) { | ||
| $scope.data.cameras = devices.filter(function(device) { | ||
| return device.kind === "videoinput"; | ||
| }); | ||
| if (c >= 0 && c < $scope.data.cameras.length) { | ||
| $scope.changeCamera(c); | ||
| } else { | ||
| console.warn("Camera index out of range:", c); | ||
| } | ||
| }).catch(function(err) { | ||
| console.error("Error enumerating devices:", err); | ||
| }); | ||
| } | ||
@@ -398,0 +407,0 @@ } |
43693
1.65%417
2.21%