Glainez commited on
Commit
67ad67b
1 Parent(s): db30738

Update select_back_camera.js

Browse files
Files changed (1) hide show
  1. select_back_camera.js +13 -10
select_back_camera.js CHANGED
@@ -1,12 +1,15 @@
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
 
 
1
+ async function access_webcam_modified(): Promise<void> {
2
+ try {
3
+ const constraints = {
4
+ video: { facingMode: "environment" }, // Request the back camera
5
+ audio: include_audio
6
+ };
7
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
8
+ video_source.srcObject = stream;
9
+ video_source.play();
10
+ // Other setup code as needed
11
+ } catch (err) {
12
+ // Error handling
13
  }
14
+ }
 
 
15