简体   繁体   English

如何使用Google Cast Chrome扩展程序投放HTML页面?

[英]How can I cast an HTML page with the Google Cast Chrome extension?

I'm building a simple web application that I want to be able to display on a TV screen using the Google Cast SDK, the Chrome browser and a Chromecast. 我正在构建一个简单的Web应用程序,我希望能够使用Google Cast SDK,Chrome浏览器和Chromecast在电视屏幕上显示。 I know with the Chromecast extension for Chrome Browser, I can cast a tab to a Chromecast device, which, from my laptop works perfectly. 我知道使用适用于Chrome浏览器的Chromecast扩展程序,我可以将标签投射到Chromecast设备,该设备可以从我的笔记本电脑中完美运行。 However, I want this exact same functionality, but available from iOS devices (iPads and iPhones) running the Chrome Browser. 但是,我想要这个完全相同的功能,但可以从运行Chrome浏览器的iOS设备(iPad和iPhone)获得。

It seems since Chrome v36 the Cast ability is baked into the iOS versions of Chrome. 从Chrome v36开始,Cast功能似乎已融入到iOS版Chrome中。 I have pulled in the Google Cast SDK per these instructions: https://developers.google.com/cast/docs/chrome_sender . 我按照以下说明提取了Google Cast SDK: https//developers.google.com/cast/docs/chrome_sender I am able to get my iPad to connect to the Chromecast, but when I try to pass in a URL to a web page... 我可以让我的iPad连接到Chromecast,但是当我尝试将URL传递到网页时......

var mediaInfo = new chrome.cast.media.MediaInfo('http://google.com');
var request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);

I get an error... 我收到一个错误......

invalid_parameter 无效的参数

I have found other, somewhat dated examples, saying I can build a custom Cast Receiver that holds an iFrame and renders the page in there, but I do not want to build a custom Cast Receiver. 我找到了其他有点过时的例子,说我可以构建一个自定义Cast接收器,它包含一个iFrame并在那里呈现页面,但我不想构建一个自定义Cast接收器。

Can I accomplish this with just a Cast Sender? 我可以使用Cast Sender完成此操作吗?

You always need a receiver on the chromecast; 你总是需要在chromecast上使用接收器; that is what gets loaded there. 那是在那里加载的。 In general, you can either use a default/styled receiver or a custom one. 通常,您可以使用默认/样式接收器或自定义接收器。 The Default or Styled receivers can only handle media so you are left with the Custom option and having an iframe is the way to go. 默认或样式接收器只能处理媒体,因此您可以使用自定义选项,并且可以使用iframe。

Chrome on iOS doesn't support casting. iOS上的Chrome不支持投射。 There's a post from early 2016 saying this on the google product forums. 2016年初有一篇帖子在谷歌产品论坛上说这个。 (But my reputation is too low to post more than two links). (但我的声誉太低,不能发布两个以上的链接)。

If it DID work, then all you would need to do is go to this site and choose the ChromeCast option and press Launch after typing in your website. 如果DID有效,那么您需要做的就是访问此网站并选择ChromeCast选项,然后在您的网站上输入后按启动键。 This does work on Chrome on desktop. 这适用于桌面版Chrome。

The source for this sender/receiver is here: https://github.com/boombatower/chromecast-dashboard 此发件人/收件人的来源是: https//github.com/boombatower/chromecast-dashboard

I've used the boombatower.github.io receiver with my own code as sender in an iOS app. 我使用了boombatower.github.io接收器和我自己的代码作为iOS应用中的发送者。 I'm also looking at whether an app extension would work, but I suspect not because of app extension limitations. 我也在考虑应用程序扩展是否可行,但我怀疑不是因为应用程序扩展限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM