Google Chromecast is a $35 media player intended to stream content such as videos from YouTube and movies from Netflix to your HD TV. About the size of a car key fob, the device connects to your wifi network and TV, and you control it via an app on your smartphone, tablet or in Google's Chrome browser.

When Google released the Cast SDK last month, I took a closer look and discovered that this diminutive device is actually running Chrome OS, a flavor of Linux, with its own Chrome browser. And, if it's running a browser, maybe I could use it to display data from Salesforce. Now that would be interesting. For $35, I could turn any HD TV or monitor into a dashboard for business data.

Chromecast

With the Chromecast extension, I could 'cast' a Chrome browser tab to my TV, essentially mirroring my laptop display, but this wasn't a very satisfying solution. If I closed my laptop, or took it out of Wifi range, the connection would break. What I really wanted was a way to to have the Chromecast load a page from Salesforce itself. This way I could leave it running independently, perhaps even updating in response to notifications from the platform.

Technical interlude: Each Chromecast app actually comprises a 'sender' and a 'receiver' part, communicating via a message bus. The sender can be an iOS, Android or HTML5 web app (the latter running on Chrome with the Chromecast extension), while the receiver is JavaScript on an HTML5 web page that the device itself loads. The sender app locate the Chromecast device on the local Wifi network (via the DIAL protocol) and instructs the device to load the receiver app from a URL. Once the receiver loads, it listens on the message bus for commands from the sender. The sender can now instruct the receiver to load and display content - perhaps stream video data from some URL. The Google Cast SDK 'Hello World' app illustrates the concept by allowing you to send a string of text from the sender, the receiver app simply displaying it on the TV.

HelloChromecast

Given this foundation, I was able to write a Node.js sender app that has you log in to Salesforce and select a Visualforce page from your org; the app then constructs a 'frontdoor.jsp' URL to send to the receiver. The receiver takes this URL and loads it into a full page iframe. Loading it into an iframe means that the receiver app can stay in the background, periodically reloading the Visualforce page to keep the session alive, and stay listening for a new URL, in case you want to switch the 'channel.'

The app, Visualforce on Chromecast, is now live on Heroku. If you have a Chromecast, and an account with API access to a Salesforce org, just click here and follow the instructions.

Screen Shot 2014-03-25 at 4.30.42 PM

If you want to dive deeper, all the code for this project is on GitHub, and I’ve written a series of three posts over at my personal blog with (much) more detail:

What device would you like to use with Salesforce? Leave a comment and let us know!

 Learn about the power of Salesforce and the new Salesforce1 with the free e-book below.

SF1_CTAbutton-2