GitXplorerGitXplorer
G

pichromecast

public
8 stars
3 forks
1 issues

Commits

List of commits on branch main.
Verified
b6bdb219b5442aa6f2c9ed9a1e58839aca3421c2

Update setup.py

GGitHub30 committed 2 years ago
Verified
2f8dad7ac4908cbbec2b636f1809395330d128ee

Update README.md

GGitHub30 committed 2 years ago
Verified
bd18f8218d4b966ea72d840a45713f3141df6c6b

Update setup.py

GGitHub30 committed 2 years ago
Verified
580b3de07ead323e268f5289afc583b0318bc426

Update README.md

GGitHub30 committed 2 years ago
Verified
02cd7ab8b9b561e2fc9a7ef18a76bf5ba7715acd

Update pichromecast.py

GGitHub30 committed 2 years ago
Verified
abd8e094855c689abe5db10298f480f82527b378

Update setup.py

GGitHub30 committed 2 years ago

README

The README file for this repository.

Python PyPI

PiChromecast

Library for MicroPython to communicate with the Google Chromecast.

Install

Tools > Manage packages...

image

or copy and paste code

https://github.com/GitHub30/pichromecast/blob/main/pichromecast.py

Usage

from pichromecast import play_url

play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')

Text to Speech

from pichromecast import play_url, create_url

play_url(create_url('hello world', 'en'), '192.168.10.101')
# https://gist.github.com/SpotlightKid/eca9b00239104e8c599b86635f62ab73#file-urlencode-py
from urlencode import urlencode
from pichromecast import play_url

url = 'https://translate.google.com/translate_tts?client=tw-ob&' + urlencode({'q': 'Hello, 世界', 'tl': 'ja'})
play_url(url, '192.168.10.101')

Connect wifi and play

import network
import time

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("aterm-SSID-g", "YOUR_PASSWORD")
while not wlan.isconnected() and wlan.status() >= 0:
    print("Waiting to connect:")
    time.sleep(1)


from pichromecast import play_url

play_url('https://nyanpass.com/nyanpass.mp3', '192.168.10.101')

image

Lookup host IP

#pip install pychromecast
import pychromecast

services, browser = pychromecast.discovery.discover_chromecasts()
pychromecast.discovery.stop_discovery(browser)
print(services)
[CastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-3b0a32dc5803130351919f8a286e406f._googlecast._tcp.local.')}, uuid=UUID('3b0a32dc-5803-1303-5191-9f8a286e406f'), model_name='Google Home Mini', friendly_name='書斎', host='192.168.10.101', port=8009, cast_type='audio', manufacturer='Google Inc.')]

or use MicroPython MDNS

Demo

Watch the video