dimanche 25 mars 2018

Accessing device camera using javascript

I want to access my device camera using javascript . But this code only works in firefox and that too on desktop . I want to access my camera on other browsers as well as mobile devices.

function start()
 {
  var video = document.getElementById('video'),
  vendorUrl = window.URL;
  navigator.mediaDevices.getUserMedia({
        video: true,
        audio: true
    })
.then(function(stream) {
  video.src = vendorUrl.createObjectURL(stream);
          video.play();
})
.catch(function(err) {
alert("no");
});

};




Aucun commentaire:

Enregistrer un commentaire