1

I'm trying to set the camera (and <video>) size to landscape using this code provided by MDN documentation:

var constraints = {
     audio: true,
     video: { width: 320, height: 180 }
};

navigator.mediaDevices.getUserMedia(constraints).then {...}

Now while this works perfectly on all browsers, for some reason, when the device is on portrait mode, Samsung browser (current version is 9.2) displays the camera input as portrait mode, diregarding my size constraints.

I've tried using exact, min and require, but the results are the same.

When the device is rotated, and is in landscape orientation, the camera is displayed with the correct sizes.

Any ideas how to resolve this issue or to workaround it?

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • just an idea of a silly workaround: calling `screen.orientation.lock('landscape');` before getting user media. – Roland Starke Jul 17 '19 at 08:12
  • @RolandStarke You mean `ScreenOrientation.lock` ? I did try that, and the video is not displayed at all... Although it's supported by Samsung Browser, seems like using this breaks something in `getUserMedia`. Thanks for the comment. – Koby Douek Jul 17 '19 at 08:15
  • yes thats what i meant (`ScreenOrientation.lock` gives me an error that lock is not a function. so i posted the code that worked for me to landscape a fullscreen video player.) – Roland Starke Jul 17 '19 at 08:29
  • 1
    I have struggled mightily with similar gUM disobedience of `constraints`. A question I asked with a large bounty turned up no useful suggestions. I think these gUM implementations need some serious hard-nosed unit tests so the browser teams can get this stuff right. – O. Jones Jul 17 '19 at 18:36

0 Answers0