EL GHAFRAOUI AYOUB commited on
Commit
255138f
·
1 Parent(s): 97a8bfb
Files changed (1) hide show
  1. static/script.js +5 -6
static/script.js CHANGED
@@ -4,21 +4,20 @@ window.addEventListener('load', function () {
4
  });
5
 
6
 
 
7
  // Function to ask for permission to access the camera
8
  function askPermission() {
 
9
  // Check if the browser supports media devices
10
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
11
  // Prompt user for permission to use the camera
12
  navigator.mediaDevices.getUserMedia({ video: true })
13
  .then(function(stream) {
 
14
  // If permission is granted, display the video stream
15
  var video = document.getElementById('videoElement');
16
- if (video) {
17
- video.srcObject = stream;
18
- video.play();
19
- } else {
20
- console.error('Video element not found in the document.');
21
- }
22
  })
23
  .catch(function(error) {
24
  // If permission is denied or an error occurs, handle it here
 
4
  });
5
 
6
 
7
+
8
  // Function to ask for permission to access the camera
9
  function askPermission() {
10
+ console.log('askPermission() function called'); // Debugging statement
11
  // Check if the browser supports media devices
12
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
13
  // Prompt user for permission to use the camera
14
  navigator.mediaDevices.getUserMedia({ video: true })
15
  .then(function(stream) {
16
+ console.log('Camera permission granted'); // Debugging statement
17
  // If permission is granted, display the video stream
18
  var video = document.getElementById('videoElement');
19
+ video.srcObject = stream;
20
+ video.play();
 
 
 
 
21
  })
22
  .catch(function(error) {
23
  // If permission is denied or an error occurs, handle it here