首页 > 解决方案 > When mobile is rotated, width and height are swapped in get User Media Api JavaScript

问题描述

I´m using the camera git getUserMedia(), but I have a big issue, because, I just set the video and height to 1280 and 720:

  videoConstraints.width = { min: 1280, ideal: 1280, max: 1280};
  videoConstraints.height = { min: 720, ideal: 720, max: 720};

It works perfect in a computer, and in a phone too, but the width and height are swapped on mobile, I have to use the mobile on landscape mode, in portrait mode the height is 1280 and width 720, and when is in landscape is height 720 and width 1280 (as I want), so i was looking for information for this, but i really does not found a really solution.

Reference to get user media API: https://developer.mozilla.org/es/docs/Web/API/MediaDevices/getUserMedia

Reference to video constraints: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints/video

标签: javascripthtmlvideomobilelandscape

解决方案


所以,然后面对这个问题我没有发现问题,我所做的是使用媒体查询为样式移动制作自定义样式。


推荐阅读