使用Chromecast显示网站和网络应用 [英] Display web sites and web apps with Chromecast
问题描述
Chromecast可以用于显示网站或网络应用程序吗?到目前为止,我所见过的所有示例发件人/收件人都展示了如何播放视频。到目前为止发布的文档尽可能少,只是一个API参考,几乎没有解释它的作用。我只想发送自己选择的URL,并在电视上显示该页面。在那之后,不需要用户交互。假设有可能,是否有人为此提供了示例Chrome发送方和接收方代码?
Can Chromecast be used to display a web site or web app? All the sample sender/receivers I've seen so far show how to play videos. The docs posted so far are minimal as best, just an API reference with little explanation what any of it does. I just want to send a URL of my choosing and have that page displayed on the TV. There's no user interaction required past that point. Assuming that's possible, does anyone have sample Chrome sender and receiver code for that?
推荐答案
我能够修改 Github示例项目> googlecast / CastHelloText-chrome
以显示网页。
I was able to modify the Github sample Project > googlecast/CastHelloText-chrome to show a web page.
- 在
receiver.html
文件中,我替换了DIV
和IFRAME
并将其样式设置为100%的宽度和高度。 - 然后在
displayText()
函数,我将innerHTML
更改为src
。 - 对发件人
chromehellotext.html
的唯一修改是将YOUR_APPLICATION_ID
替换为创建的应用程序ID通过注册接收方。
- In the
receiver.html
file, I replaced theDIV
with anIFRAME
and styled it for 100% width and height. - Then in the
displayText()
function I changedinnerHTML
tosrc
. - The only modification made to the sender
chromehellotext.html
was to replaceYOUR_APPLICATION_ID
with the app id created by registering the receiver.
注意,某些网站(例如Google和Yahoo)将不会显示在iframe中。如果确实需要这样做,则可以跳过iframe,只需将 window.location.href
设置为URL。当然,那会覆盖您的接收者代码,因此更改URL的唯一方法是先手动断开连接并重新加载。我尝试使用 window.open
代替,但这不起作用。
Note that some sites like Google and Yahoo will not display inside an iframe. If you really needed to do that you could skip the iframe and just set window.location.href
to the URL. That, of course, will overwrite your receiver code so the only way to change URLs would be to manually disconnect first and reload. I tried using window.open
instead but that did not work.
这篇关于使用Chromecast显示网站和网络应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!