user0721090601
user0721090601

Reputation: 5346

Using Chromecast with packaged Chrome apps

I'm working to create a sender app in Chrome (34.0.1847.137, on 10.9), but rather than merely be a standard webpage, I'd like to package it into a Chrome App.

All of my code works fine tested as a standard webpage, but when packaged as an app, because there is no Chromecast button (normally next to address bar), it seems impossible to let the user even know that it's there even though through the console I can see that a receiver was identified.

Is there a way to reveal that button to the user or (even better) programmatically launch the receiver app on the Chromecast without needing the user to press any buttons?

Upvotes: 1

Views: 203

Answers (2)

lostsource
lostsource

Reputation: 21850

One workaround would be to use the chrome.sockets.tcpServer API to create your own web server and then serve a page which uses the Chrome Cast Chrome Sender API

You would still require users to install the official Google Cast extension, it will act as a bridge between your packaged app and the Chromecast device.

If you would like to see this in action you can check out an app which uses this solution here:

https://chrome.google.com/webstore/detail/flair-player/mpkhmenokpjamhajlajnldibdjkacgcp

As you can see below, the address 127.0.0.1:8010/index.html is served using the chrome.sockets.tcpServer API, it then communicates with the Google Cast extension, and messages are sent between the app and the extension/device using AJAX.

Page served by Chrome app using chrome.sockets.tcpServer

Upvotes: 2

JeremyatGoogleLA
JeremyatGoogleLA

Reputation: 86

Unfortunately, the Chromecast API isn't compatible with packaged apps quite yet. It's a known issue that's being worked on so hopefully it won't be a problem for much longer! In the mean time, you can track this Chrome bug to stay in the loop:

https://code.google.com/p/chromium/issues/detail?id=287254

Upvotes: 1

Related Questions