File: youtube_example.py

package info (click to toggle)
pychromecast 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 332 kB
  • sloc: python: 1,751; makefile: 6; sh: 3
file content (23 lines) | stat: -rw-r--r-- 557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Example on how to use the YouTube Controller

"""

import pychromecast
from pychromecast.controllers.youtube import YouTubeController


# Change to the name of your Chromecast
CAST_NAME = "Living Room TV"

# Change to the video id of the YouTube video
# video id is the last part of the url http://youtube.com/watch?v=video_id
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)