cordova-plugin-iosrtc: Webrtc-adapter mediaConstraints.video.facingMode does not select correct camera
Expected behavior
Hi, I’m using the plugin to get AR.js to work in cordova-ios. With some adjustment on the AR.js code the video is loaded and should show the environment camera.
Observerd behavior
But I only get the selfie camera selected.
Steps to reproduce the problem
I used the bootstrap code to patch the global API, then started AR.js. The code in AR.js is:
navigator.mediaDevices.enumerateDevices().then(function (devices) {
var userMediaConstraints = {
audio: false,
video: {
facingMode: {
ideal: 'environment'
},
width: {
ideal: _this.parameters.sourceWidth,
// min: 1024,
// max: 1920
},
height: {
ideal: _this.parameters.sourceHeight,
// min: 776,
// max: 1080
}
}
};
// get a device which satisfy the constraints
navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
// set the .src of the domElement
domElement.srcObject = stream;
var event = new CustomEvent('camera-init', {stream: stream});
window.dispatchEvent(event);
// to start the video, when it is possible to start it only on userevent. like in android
document.body.addEventListener('click', function () {
domElement.play();
});
// domElement.play();
})
});
})
});
[...]
Are there any other things I have to define, set or pay attention to?
Platform information
- Cordova version: 9.0.0
- Plugin version: 5.0.1
- iOS version: 13.2.3 (iPhone 7 & XR)
- Xcode version: 12.2.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (11 by maintainers)
Ah ok, the z-indices are set correctly by AR.js.
Sure:
Missing typeof released on 6.0.5
with webrtc adapter
I think, I found the problem in the getUserMedia.js.
But the adapter writes the sourceId to constraints.video.mandatory.sourceId.
without webrtc adapter
The constraints inside getUserMedia.js are the original constrains from the AR.js call. But:
The Browser evaluates
(constraints.video.facingMode.ideal === 'string')
as false, so the facing mode is not passed into the native plugin code.PS: there is
typeof
missing:(**typeof** constraints.video.facingMode.ideal === 'string')