How to use the pychromecast.get_chromecast function in PyChromecast

To help you get started, we’ve selected a few PyChromecast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KeizerDev / Rhythmbox-Chromecast / ChromecastSource.py View on Github external
def setup(self):
        if self.isPluginActivated:
            return

        shell = self.get_property("shell")
        player = shell.get_property("shell-player")

        self.shell = shell
        self.player = player
        self.db = shell.get_property("db")

        self.chromecast = pychromecast.get_chromecast(friendly_name=Prefs.chromecastName)
        self.chromecast.wait()
        # self.chromecastPlayer = self.chromecast.media_controller

        self.chromecastListeners = ChromecastListeners.ChromecastListeners(self.chromecast)

        self.shell_cb_ids = (
            self.player.connect('playing-song-changed', self.chromecastListeners.song_changed_cb),
            self.player.connect('playing-changed', self.chromecastListeners.player_changed_cb)
        )

        self.draw_sidebar()


        model = self.get_property("query-model")
        playing_entry = player.get_playing_entry()
        # If the current playing entry is not in the playing source's
github ains / aircast / src / cast.py View on Github external
def __init__(self, stream_url):
        self.stream_url = stream_url

        logger.info("Searching for Chromecast devices...")
        chromecast_list = pychromecast.get_chromecasts_as_dict().keys()
        logger.debug("Found Chromecasts: %s", chromecast_list)

        if not chromecast_list:
            raise RuntimeError("Unable to find a Chromecast on the local network.")

        chromecast_name = chromecast_list[0]
        if len(chromecast_list) > 1:
            logger.warn("Multiple Chromecast devices detected, using defaulting to Chromecast '%s'", chromecast_name)

        logger.info("Connecting to Chromecast '%s'", chromecast_name)
        self.chromecast = pychromecast.get_chromecast(
            friendly_name=chromecast_name)
        self.chromecast.wait()
        logger.info("Connected to Chromecast '%s'", chromecast_name)
github erik / alexacast / server.py View on Github external
def server(device):
    global cast
    global device_name

    print('>> trying to connect to {}'.format(device))

    device_name = device
    cast = pychromecast.get_chromecast(friendly_name=device)
    if cast is None:
        click.echo("Couldn't find device '{}'".format(device))
        sys.exit(-1)

    print(repr(cast))
    print('connected, starting up...')

    app.run('0.0.0.0', 8183)
github dohliam / stream2chromecast / stream2chromecast.py View on Github external
def get_chromecast():
    """ create an instance of the chromecast device """
    cast = pychromecast.get_chromecast()

    time.sleep(1)
    print    
    print cast.device
    print
    print cast.status
    print
    print cast.media_controller.status
    print    
    
    return cast
github touchandgo-devs / touchandgo / touchandgo / output.py View on Github external
def run(self):
        chromecast = self.parent.chromecast
        device = pychromecast.get_chromecast(friendly_name=chromecast)
        interface = get_interface()
        guess = self.parent.guess(self.parent.get_video_path())
        device.play_media("http://%s:%s" % (interface, self.parent.port),
                          guess['mimetype'])
        while True:
            sleep(1)
github stefanor / chromecastplayer / chromeplay.py View on Github external
def play(url):
    while True:
        try:
            cast = pychromecast.get_chromecast()
            while not cast.is_idle:
                cast.quit_app()
                time.sleep(1)

            time.sleep(1)
            cast.play_media(url, "video/mp4")
        except socket.error as e:
            if e.errno != errno.EFAULT:
                raise
        except ssl.SSLError as e:
            pass
        else:
            break

    control_loop(cast.media_controller)
    cast.quit_app()
github Pizzaface / Alexa-Chromecast-Skill / chromecastPlayVideo.py View on Github external
cur.execute("SELECT * FROM saved_chromecasts WHERE `friendly_name` = \""+ str(escaped) +"\" LIMIT 1 ;")
		print cur.fetchall()
		for row in cur.fetchall():
			if row[1] == chromecastList[x]:
				exists = True
			else:
				exists = False


			if not exists == True:
				print escaped + " was added."
				cur.execute("INSERT INTO  `saved_chromecasts` (`friendly_name`) VALUES (`"+ str(escaped) + "`);")



cast = pychromecast.get_chromecast(friendly_name="Jordan's Chromecast")
while True:
    dbConnect()
    time.sleep(2)
github muammar / mkchromecast / mkchromecast / cast.py View on Github external
def _get_chromecast(self, name):
        # compatibility
        try:
            return pychromecast.get_chromecast(friendly_name=self.cast_to)
        except AttributeError:
            return self._chromecasts_by_name[name]