Python Chromecast

Thanks to the pychromecast library. It supports the following features,

  • Auto discovering connected Chromecasts on the network
  • Start the default media receiver and play any online media
  • Control playback of current playing media
  • Implement Google Chromecast api v2
  • Communicate with apps via channels
  • Easily extendable to add support for unsupported namespaces
  • Multi-room setups with Audio cast devices

How to use pychromecast?

Install pychromecast using pip.

pip install pychromecast
from __future__ import print_function
import time
import pychromecast

# Your Chromecast device Friendly Name
device_friendly_name = "VuCast"

chromecasts = pychromecast.get_chromecasts()

# select Chromecast device
cast = next(cc for cc in chromecasts if cc.device.friendly_name == device_friendly_name)

# wait for the device

# get media controller 
mc = cast.media_controller
# set online video url
mc.play_media('', 'video/mp4')

# blocks device

# plays the video

This is merely an example, This opens lot of possiblities controlling Chromecast with python.