I'm using getUserMedia
with the following constraints:
var constraints = {
audio: true,
video: {
width: 960,
height: 540,
}
};
navigator.mediaDevices.getUserMedia(constraints).then(...);
This works when using desktops or when using mobile devices while they are in landscape mode. However, when rotating the mobile device to portrait mode, the video object loses the aspect ratio:
When the device is held as Landscape:
When the device is held as Portrait:
This happens both on iOS and Android devices, on Chorme, Safari and Samsung browser.
I tried playing around with the constraints aspectRatio
, min
, ideal
as suggested by the MDN docs, but it seems these constraints are of no effect at all.
Is there any way to always maintain the aspect ratio as 1.777 even if the mobile device is rotated as portrait mode?