I am using MediaDevices
to use webcam in my angular2 application. I have 2 webcams and I am stuck in switching between 2 webcams. Here is the code I am using right now.
navigato.mediaDevices.getUserMedia(constraints)
.then(function (stream) {
var video: any = document.getElementById('my_camera');
// Older browsers may not have srcObject
if (video && "srcObject" in video) {
video.srcObject = stream;
} else {
// Avoid using this in new browsers, as it is going away.
video.src = window.URL.createObjectURL(stream);
}
video.onloadedmetadata = function (e) {
video.play();
selff.webCam = true;
};
})
.catch(function (err) {
console.log(err.name + ": " + err.message);
});
I have also tried webcamjs library but could not find switching camera functionality in it.