
So you’ve got P圜hromecast running and decided it is time to add support to your favorite app. For an example of a fully implemented controller see the MediaController. When a message is received with your namespace it will be routed to your controller.įor more options see the BaseController. _init_ ( "urn:x-cast:my." ) def receive_message ( self, message, data ): print ( "Wow, I received this message: )Īfter you have defined your controller you will have to add an instance to a Chromecast object: cast.register_handler(M圜ontroller()). Example of a minimal controller: from ntrollers import BaseController class M圜ontroller ( BaseController ): def _init_ ( self ): super ( M圜ontroller, self ). To add your own namespace to a current chromecast instance you will first have to define your controller. Support for extra namespaces is added by using controllers. This is used to communicate between theĬhromecast and your phone/browser and now Python. stop_discovery ( browser )Įach app that runs on the Chromecast supports namespaces. play () > # Shut down discovery > pychromecast. status ) MediaStatus ( current_time = 42.458322, content_id = '', content_type = 'video/mp4', duration = 596.474195, stream_type = 'BUFFERED', idle_reason = None, media_session_id = 1, playback_rate = 1, player_state = 'PLAYING', supported_media_commands = 15, volume_level = 1, volume_muted = False ) > mc. status ) CastStatus ( is_active_input = True, is_stand_by = False, volume_level = 1.0, volume_muted = False, app_id = 'CC1AD845', display_name = 'Default Media Receiver', namespaces =, session_id = 'CCA39713-9A4F-34A6-A8BF-5D97BE7ECA5C', transport_id = 'web-9', status_text = '' ) > mc = cast.

device ) DeviceStatus ( friendly_name = 'Living Room', model_name = 'Chromecast', manufacturer = 'Google Inc.', uuid = UUID ( 'df6944da-f016-4cb8-97d0-3da2ccaa380b' ), cast_type = 'cast' ) > print ( cast.

get_listed_chromecasts ( friendly_names = ) > cast = chromecasts > # Start worker thread and wait for cast device to be ready > cast. stop_discovery ( browser ) > # Discover and connect to chromecasts named Living Room > chromecasts, browser = pychromecast. discover_chromecasts () > # Shut down discovery > pychromecast.
#ANDROID EMULATOR ON MAC TO RUN SPOTIFY DESKTOP TO CHROMECAST HOW TO#
How to use > import time > import pychromecast > # List chromecasts on the network, but don't connect > services, browser = pychromecast.
