platypush.plugins.media.chromecast

class platypush.plugins.media.chromecast.MediaChromecastPlugin(chromecast=None, *args, **kwargs)[source]

Plugin to interact with Chromecast devices

Supported formats:

  • HTTP media URLs
  • YouTube URLs
  • Plex (through media.plex plugin, experimental)

Requires:

  • pychromecast (pip install pychromecast)
__init__(chromecast=None, *args, **kwargs)[source]
Parameters:chromecast (str) – Default Chromecast to cast to if no name is specified
disconnect(chromecast=None, timeout=None, blocking=True)[source]

Disconnect a Chromecast and wait for it to terminate

Parameters:
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
  • timeout (float) – Number of seconds to wait for disconnection (default: None: block until termination)
  • blocking (bool) – If set (default), then the code will wait until disconnection, otherwise it will return immediately.
get_chromecasts(tries=2, retry_wait=10, timeout=60, blocking=True, callback=None)[source]

Get the list of Chromecast devices

Parameters:
  • tries (int) – Number of retries (default: 2)
  • retry_wait (int) – Number of seconds between retries (default: 10 seconds)
  • timeout (int) – Timeout before failing the call (default: 60 seconds)
  • blocking (bool) – If true, then the function will block until all the Chromecast devices have been scanned. If false, then the provided callback function will be invoked when a new device is discovered
  • callback (func) – If blocking is false, then you can provide a callback function that will be invoked when a new device is discovered
join(chromecast=None, timeout=None)[source]

Blocks the thread until the Chromecast connection is terminated.

Parameters:
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
  • timeout (float) – Number of seconds to wait for disconnection (default: None: block until termination)
mute(chromecast=None)[source]

Toggle the mute status on the Chromecast

Parameters:chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
play(resource, content_type=None, chromecast=None, title=None, image_url=None, autoplay=True, current_time=0, stream_type='BUFFERED', subtitles=None, subtitles_lang='en-US', subtitles_mime='text/vtt', subtitle_id=1)[source]

Cast media to a visible Chromecast

Parameters:
  • resource (str) – Media to cast
  • content_type (str) – Content type as a MIME type string
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
  • title (str) – Optional title
  • image_url (str) – URL of the image to use for the thumbnail
  • autoplay (bool) – Set it to false if you don’t want the content to start playing immediately (default: true)
  • current_time (int) – Time to start the playback in seconds (default: 0)
  • stream_type (str) – Type of stream to cast. Can be BUFFERED (default), LIVE or UNKNOWN
  • subtitles (str) – URL of the subtitles to be shown
  • subtitles_lang (str) – Subtitles language (default: en-US)
  • subtitles_mime (str) – Subtitles MIME type (default: text/vtt)
  • subtitle_id (int) – ID of the subtitles to be loaded (default: 1)
quit(chromecast=None)[source]

Exits the current app on the Chromecast

Parameters:chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
reboot(chromecast=None)[source]

Reboots the Chromecast

Parameters:chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
set_volume(volume, chromecast=None)[source]

Set the Chromecast volume

Parameters:
  • volume (float) – Volume to be set, between 0 and 100
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
voldown(chromecast=None, step=10)[source]

Turn down the Chromecast volume by 10% or step.

Parameters:
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
  • step (float) – Volume decrement between 0 and 100 (default: 100%)
volup(chromecast=None, step=10)[source]

Turn up the Chromecast volume by 10% or step.

Parameters:
  • chromecast (str) – Chromecast to cast to. If none is specified, then the default configured Chromecast will be used.
  • step (float) – Volume increment between 0 and 100 (default: 100%)