I want to get the video stream of my rear camera in an Ionic Application. For this, I use getUserMedia that work correctly for the front camera.
When I change the facing mode to 'environment' I got this error :
Unknown constraint named facingMode rejected
ConstraintNotSatisfiedError
In my Ionic application I have already installed the npm package "webrtc-adapter".
Here is my code to get the stream from the rear camera :
this.constraints = { audio: true, video: {mandatory: { facingMode: 'environment'}}};
cordova.plugins.diagnostic.requestRuntimePermission( (status) => {
if (cordova.plugins.diagnostic.permissionStatus.GRANTED){
navigator.getUserMedia(this.constraints, (stream) => {
let video = <HTMLVideoElement>document.getElementById('localVideo');
video.srcObject = stream;
}, function(err){
console.log("Error get stream: ", err.name);
});
}
}, (error) => {
console.error("Error during runtime permission :", error);
}, cordova.plugins.diagnostic.permission.CAMERA);
I think that is a compatibility issue. Anyone can help me ?
Thank you.