Check camera access

by maheshBongani

HTML

<!DOCTYPE html>
<html>

<head>
</head>

<body>
	<video autoplay></video>
  <select></select>
	<button id="turnOn">turnOn Camera</button>
	<button id="capture">Capture</button>
	<canvas id="canvas" width=320 height=240></canvas>
	<script>
  
	</script> 
</body>

</html>

JavaScript

const turnOnButton = document.getElementById('turnOn');

turnOnButton.addEventListener('click', () => {

navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

navigator.getMedia({video: true}, function() {
  // webcam is available
  ale('available');
}, function() {
  // webcam is not available
  console.log('not available');
});

    });