class DashCastController(CastController): def __init__(self, cast, app, prep=None): self._controller = PyChromecastDashCastController() super(DashCastController, self).__init__(cast, app, prep=prep) def load_url(self, url, **kwargs): self._controller.load_url(url, force=True) def prep_app(self): """Make sure desired chromecast app is running.""" # We must force the launch of the DashCast app because it, by design, # becomes unresponsive after a website is loaded. self._cast.start_app(self._cast_listener.app_id, force_launch=True) self._cast_listener.app_ready.wait()
class DashCastController(CastController): def __init__(self, cast, app, prep=None): self._controller = PyChromecastDashCastController() super(DashCastController, self).__init__(cast, app, prep=prep) def load_url(self, url, **kwargs): self._controller.load_url(url, force=True) def prep_app(self): """Make sure desired chromecast app is running.""" # We must force the launch of the DashCast app because it, by design, # becomes unresponsive after a website is loaded. self._cast.start_app(self._cast_listener.app_id, force_launch=True) self._cast_listener.app_ready.wait()
async def play_media(call: ServiceCall): entity_ids = call.data.get(ATTR_ENTITY_ID) url = call.data.get('url') force = call.data.get('force', False) for entity in hass.data[DATA_INSTANCES][MP_DOMAIN].entities: if entity.entity_id in entity_ids: dash = dashs.get(entity.entity_id) if not dash: dashs[entity.entity_id] = dash = DashCastController() entity._chromecast.register_handler(dash) dash.load_url(url, force)
def _setup_controllers(self): self.ctls = Controllers( YouTubeController(), DashCastController(), PlexController(), SuplaController(), # BbcIplayerController(), # BbcSoundsController(), # BubbleUPNPController(), # YleAreenaController(), # PlexApiController(), # HomeAssistantController(), ) for ctl in self.ctls: if ctl: self._register(ctl)
def dash_cast(hass: HomeAssistantType, cast_entities: list, url: str): """Cast webpage to chromecast device via DashCast application.""" try: entities = [ e for e in hass.data[DATA_INSTANCES]['media_player'].entities if e.entity_id in cast_entities and getattr(e, '_chromecast', 0) ] if not entities: _LOGGER.warning(f"Can't find {cast_entities} for DashCast") for entity in entities: from pychromecast.controllers.dashcast import DashCastController if not hasattr(entity, 'dashcast'): entity.dashcast = DashCastController() entity._chromecast.register_handler(entity.dashcast) _LOGGER.debug(f"DashCast to {entity.entity_id}") entity.dashcast.load_url(url) except: _LOGGER.exception(f"Can't DashCast to {cast_entities}")
def __init__(self, cast, app, prep=None): self._controller = PyChromecastDashCastController() super(DashCastController, self).__init__(cast, app, prep=prep)
def __init__(self, cast, app, prep=None): self._controller = PyChromecastDashCastController() super(DashCastController, self).__init__(cast, app, prep=prep)