Spaces:
Sleeping
Sleeping
Update select_back_camera.js
Browse files- select_back_camera.js +11 -17
select_back_camera.js
CHANGED
@@ -1,18 +1,12 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
backCameraOption.selected = true;
|
12 |
-
const event = new Event('change', { bubbles: true });
|
13 |
-
backCameraOption.parentElement.dispatchEvent(event);
|
14 |
-
}
|
15 |
-
}, 500); // Adjust timeout as necessary to ensure dropdown is populated
|
16 |
-
}
|
17 |
-
}, 1000);
|
18 |
});
|
|
|
|
1 |
+
navigator.mediaDevices.getUserMedia({
|
2 |
+
video: { facingMode: "environment" }
|
3 |
+
}).then(stream => {
|
4 |
+
// Use the stream, for example, attach it to a video element
|
5 |
+
let video = document.querySelector('video');
|
6 |
+
if (video) {
|
7 |
+
video.srcObject = stream;
|
8 |
+
}
|
9 |
+
}).catch(error => {
|
10 |
+
console.error('Error accessing the camera', error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
});
|
12 |
+
|