Skip to content

Instantly share code, notes, and snippets.

@Yuiki
Created August 26, 2018 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yuiki/86450bca93b0b0e8a74f3b2c3892cbc9 to your computer and use it in GitHub Desktop.
Save Yuiki/86450bca93b0b0e8a74f3b2c3892cbc9 to your computer and use it in GitHub Desktop.
Play YouTube on Chrome Cast
import pychromecast
from pychromecast.controllers.youtube import YouTubeController
CAST_NAME = ""
VIDEO_ID = ""
chromecasts = pychromecast.get_chromecasts()
cast = next(cc for cc in chromecasts if cc.device.friendly_name == CAST_NAME)
cast.wait()
yt = YouTubeController()
cast.register_handler(yt)
yt.play_video(VIDEO_ID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment