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

喜欢而已 提交于 2019-12-23 09:48:18

问题


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. I know with the Chromecast extension for Chrome Browser, I can cast a tab to a Chromecast device, which, from my laptop works perfectly. However, I want this exact same functionality, but available from iOS devices (iPads and iPhones) running the Chrome Browser.

It seems since Chrome v36 the Cast ability is baked into the iOS versions of Chrome. I have pulled in the Google Cast SDK per these instructions: 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...

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.

Can I accomplish this with just a Cast Sender?


回答1:


You always need a receiver on the 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.




回答2:


Chrome on iOS doesn't support casting. There's a post from early 2016 saying this on the google product forums. (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. This does work on Chrome on desktop.

The source for this sender/receiver is here: https://github.com/boombatower/chromecast-dashboard

I've used the boombatower.github.io receiver with my own code as sender in an iOS app. I'm also looking at whether an app extension would work, but I suspect not because of app extension limitations.



来源:https://stackoverflow.com/questions/27049265/how-can-i-cast-an-html-page-with-the-google-cast-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!