Turn off camera after photo
<p>I am reverse-engineering a project and am running into some perplexing problems. The project is in Meteor, which I like, but doesn't seem to follow Meteors conventions. </p>

<p>This is essentially a javascript file to allow users to take a selfie using the laptop devices camera. However, after taking the photo, the camera does not turn off.</p>

<p>After having tried a number of suggestions online, I am putting the question: how does one turn off the camera? </p>

<p>Thank you for your help!</p>

<pre><code>    Template.newSelfie.rendered = function(){

      // Grab elements, create settings, etc.
      var canvas = document.getElementById("canvas"),
        context = canvas.getContext("2d"),
        video = document.getElementById("video"),
        videoObj = { "video": true },
        errBack = function(error) {
          console.log("Video capture error: ", error.code);
        };

      // Put video listeners into place
      if(navigator.getUserMedia) { // Standard
        navigator.getUserMedia(videoObj, function(stream) {
          video.src = stream;
          video.play();
        }, errBack);
      } else if(navigator.webkitGetUserMedia) { // WebKit-prefixed
        navigator.webkitGetUserMedia(videoObj, function(stream){
          video.src = window.webkitURL.createObjectURL(stream);
          video.play();
        }, errBack);
      }
      else if(navigator.mozGetUserMedia) { // Firefox-prefixed
        navigator.mozGetUserMedia(videoObj, function(stream){
          video.src = window.URL.createObjectURL(stream);
          video.play();
        }, errBack);
      }

      // Converts canvas to an image
      function convertCanvasToImage(canvas) {
        var image = new Image();
        image.src = canvas.toDataURL("image/png");
        return image.src;
      }

      $('#take-selfie').click(function() {
        context.drawImage(video, 0, 0, 450, 350);
        var selfieImg = convertCanvasToImage(canvas);

        Posts.insert({
          ownerId: Meteor.userId(),
          userWallId: Meteor.userId(), 
          content: '&lt;img src="'+selfieImg+'"&gt;',
          postedOn: new Date()
        }, function(err, res) {
          console.log(err || res);
        });

        Selfies.insert({
          ownerId: Meteor.userId(),
          image: selfieImg,
          postedOn: moment().format('MM/DD/YYYY hh:mm a'),
          createdAt: moment().format('YYYY-MM-DD')
        }, function(err, res) {
            console.log(err || res);
            if(err){
              console.log(err);
            } else {
              Router.go('profileSelfies');
            }
        });
      });       
    };
</code></pre>