I\'m working on a project with MVC ASP.Net 4 HTML5 (default browser is google-chrome v29.0.1547.57) I can interact with these tools and take photographs but only with front
A demo can be found at https://webrtc.github.io/samples/src/content/devices/input-output/. This will allow access to both the front and rear camera.
Many demos that you will find rely on the deprecated function:
MediaStreamTrack.getSources()
As of Chrome 45 and FireFox 39, you will need to use the function:
MediaDevices.enumerateDevices()
Example:
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
console.log("enumerateDevices() not supported.");
return;
}
// List cameras and microphones.
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
devices.forEach(function(device) {
console.log(device.kind + ": " + device.label +
" id = " + device.deviceId);
});
})
.catch(function(e) {
console.log(e.name + ": " + e.message);
});
Further documentation can be found here: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices