Chromecast - Displaying arbitrary URLs using pychromecast

Mon 25 August 2014 by Fred Clift

Continuing on with my Chromecast experiments... I have been playing with a python library on github by Paulus Schoutsen called pychromecast. At various points in it's life it has been able to interact with Chromecast devices to do a variety of things. With the official SDK release and firmware update from google earlier this year, much of that broke. It can however find devices on my local network, and get device status, and a few other things.

Referring back to my last post, my ideal app for the chromecast would be a daemon running on my Mac or FreeBSD box that will watch the device for inactivity and, if it wasn't doing anything else, would cause photos or home videos to be streamed to the device.

You may recall that I recently was learning about remote chrome browser debugging. If you register for a Developer Account with google, you can whitelist your Chromecast and get it put in development mode. Once in development mode, the device turns on remote chrome debugging on the standard port 9222.

I dug around to find out about the protocol the debugger speaks over that debug port. You can read all about the Chrome Remote Debugging protocol but here is a brief over view. There is a very simple web server running on that port that gives you a link for each tab showing in Chrome, or in this case each tab showing on your Chromecast. If you click that link, it will actually open the Chrome debugger, connected to a websocket on the device. You can enumerate what the websocket endpoints are - http://cast-IP:9222/json - you get a small bit of json back listing all the details of your open tabs.

>> curl
[ {
  "devtoolsFrontendUrl": "/devtools/devtools.html?host=",
  "faviconUrl": "",
  "thumbnailUrl": "/thumb/chrome://newtab/",
  "title": "New Tab",
  "url": "chrome://newtab/",
  "webSocketDebuggerUrl": "ws://"
} ]

If you make a websocket connection to webSocketDebuggerUrl you can speak the remote debugging api to your browser, or remote Chromecast-in-developer-mode device.

A "quick" persual of the api docs shows a function that I need. Page.navigate

If you send

{"id":0, "method":"Page.navigate", "params":{"url":""}}

over the wire, then presto, what you see on your TV is my website.

You dont have to do all the work yourself. Paulus has been kind enough to merge my code into pychromecast.


If you join the Google developer program for $5, and install pychromecast, you can do this very simply:

>> devices = pychromecast.get_chromecasts_as_dict()
>> devices['castdevicename'].crd_open_url("")

This wont work for any old device, and you can't ship apps that work this way, but for my "ideal" app, It should be pretty simple, with pychromecast. I've got a rudimentary proof of concept working now.

Note that shipping apps that do this would be against Googles TOS, and they wouldn't work anyway...

Have fun with your personal projects.

P.S. Someone else did this in ruby too!