获取Chromecast接收器用户界面的实际宽度 [英] Getting actual width of Chromecast receiver UI

查看:55
本文介绍了获取Chromecast接收器用户界面的实际宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将第二代Chromecast连接到了显示器.我正在从Chromecast接收1080p60.

我不确定这是否会在Stack Overflow的图像视图中出现,但是测试图像是否完美.我可以看到每一行,这意味着该图像实际上以1920x1080的分辨率显示.

因此,看来文档并没有说明全部.实际上,UI是在输出分辨率下呈现的...在我的情况下为1920x1080.但是它使用的是1280x720的虚拟像素大小.我宁愿访问完整分辨率,所以我添加了适当的视口元标记,就像在移动设备上一样:

 <元名称=视口"内容=宽度=设备宽度,初始比例= 1"./> 

不幸的是,这没有效果!视口即使在现实中也能以更高的分辨率渲染,仍为1280x720.

有什么办法解决这个问题吗?

解决方案

必须获得接收器分辨率,才发现 cast.framework.CastReceiverContext.getInstance().canDisplayType 实际上是当前输出解决方案.

这是我的快速丑陋技巧,可获取视频输出的当前显示分辨​​率.

 (()=> {var x = 0,y = 1,i = cast.framework.CastReceiverContext.getInstance();while(i.canDisplayType("video/mp4",,",++ x,y));X - ;while(i.canDisplayType("video/mp4",",x,++ y)));y--;返回{width:x,height:y};})() 

显然,可以通过预定义的分辨率或仅进行一些二进制搜索来使其更漂亮.

随时发布更好的解决方案.:)

I have a second generation Chromecast connected to a monitor. I'm receiving 1080p60 from the Chromecast.

The Cast documentation states in several places that the UI is at the resolution of 720p:

While Chromecast displays the receiver page on a 720p graphics plane, other Cast platforms including Android TV may display the page up to 1080p.

And, this note on media formats:

Images have a display size limitation of 720p (1280x720). Images should be optimized to 1280x720 or less to avoid scaling down on the receiver device.

Indeed, if you open a debugging console on a receiver application, you can see that window.innerWidth is 1280, and window.innerHeight is 720.

This led me to believe that video was hardware decoded to its own layer, directly to the video output, and the browser-based UI was rendered at a lower resolution and overlaid on top of it. But then, I saw the <video> element in the DOM itself and wondered how this could work. For a moment, I thought it might be controlling some background hardware player, but this video can be manipulated with CSS, so that didn't make any sense.

I added a 1920x1080 test image to the web UI and did a capture.

I'm not sure if this will come across on Stack Overflow's image view, but the test image was perfect. I could see every line, meaning the image was in fact displayed at 1920x1080.

So, it seems the documentation doesn't tell the whole story. The UI is in fact rendered at the output resolution... 1920x1080 in my case. But it uses a virtual pixel size of 1280x720. I would rather access the full resolution, so I added the appropriate viewport meta tag, like I would for mobile:

<meta name="viewport" content="width=device-width, initial-scale=1" />

Unfortunately, this has no effect! The viewport is still 1280x720, even though it is rendering at higher resolutions in reality.

Is there any way around this?

解决方案

Had to get the receiver resolution, figured out that cast.framework.CastReceiverContext.getInstance().canDisplayType actually takes the current output resolution into account.

Here is my quick ugly hack to get the current display resolution of the video output.

(() => {
var x = 0, y = 1, i = cast.framework.CastReceiverContext.getInstance();
while(i.canDisplayType("video/mp4", "", ++x, y));
x--;
while(i.canDisplayType("video/mp4", "", x,++y));
y--;
return {width: x, height: y};
})()

This can obviously be made prettier with either predefined resolutions or just some binary searching.

Feel free to post a nicer solution. :)

这篇关于获取Chromecast接收器用户界面的实际宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆