0

I have this code in accessing the webcam and i dont know how to stop the webcam after clicking the close button. how do i return it to false?

function camera() {
    var video = document.getElementById('video'),
    canvas = document.getElementById('canvas'),
    context = canvas.getContext('2d'),
    photo = document.getElementById('photo'),
    vendorUrl = window.URL || window.webkitURL;

    navigator.getMedia = navigator.getUserMedia ||
                     navigator.webkitGetUserMedia ||
                     navigator.mozGetUserMedia ||
                     navigator.msGetUserMedia;

    navigator.getMedia({
        video: true,
        audio: false,
        cornerRadius: 60
    }, function(stream){
        video.src = vendorUrl.createObjectURL(stream);
        video.play();
    }, function(error) {
        // An error occured
        // eror.code
    });

    document.getElementById('capture').addEventListener('click', function(){
        context.drawImage(video, 0, 0, 400, 300);
        photo.setAttribute('src', canvas.toDataURL('img/png'));
    });

}
Steve
  • 1,553
  • 2
  • 20
  • 29

0 Answers0