16

我打电话getUserMedia()来获取视频流并简单地将 设置streamsrcObject视频元素的。

特别是在 2 个不同 Windows 平板电脑上的 Chrome 上,在纵向模式下,视频是侧面的。

我在流或视频轨道对象中找不到任何方向信息,并且宽度和高度轨道信息与视频元素匹配并且与纵横比轨道信息准确。

您可以使用https://camera.stackblitz.io进行复制

如何从流中获取方向信息或逻辑旋转视频?

编辑:

我不想要设备或屏幕的方向,而是视频流的方向。也许“轮换”是正确的措辞。换句话说,我怎么知道什么时候在没有人看的情况下旋转视频?

编辑2:

“纵向模式下的 Windows 平板电脑上的 Chrome”正是我所经历的 我不知道问题是否与此无关,或者每个 Windows 平板电脑都有问题,但主要问题是我如何判断视频是横向还是旋转?

4

2 回答 2

1

As far as I know,

Orientation is in the field of screen not stream.

The Screen Orientation API provides the ability to read the screen orientation type and angle, to be informed when the screen orientation state changes, and be able to lock the screen orientation to a specific state.

In my view, one great method for managing orientation is using media query like below:

/* 
  ##Device = Tablets, Ipads (portrait)
  ##Screen = B/w 768px to 1024px
*/

@media (min-width: 768px) and (max-width: 1024px) {

  //CSS

}

For using other methods like JavaScript or manifest please see this article.

Edit

You mentioned in title of question to Windows Tablet and also you mentioned you are looking for a way for setting orientation options without a human looking at it.The your second condition contradicts the former.

How we do detect device is Windows Tablet without a human looking at video??

It's not possible to answer this question. I think your view about stream is wrong.

You can choose one of them at a time:

  1. If you need to detect some devices like Windows Tablet, you can use some thing like media query or JavaScript method to detect device.
  2. If you need to set option without a human looking at it, you can use some method like MediaStreamTrack.applyConstraints().
于 2018-03-27T06:21:40.397 回答
0

您可以通过 javascript 获取方向信息screen.orientation。参见MDN 文档

于 2018-03-26T12:44:44.980 回答