A simple Python server with web UI to control Chromecast, play local media files via Chromecast.
Archived because I basically don't use Chromecast anymore.
If you somehow find this useful, you can fork the repo.
Or use the code as long as it's non-commercial.
pip install -r requirements.txt
:
bottle
: fast and simple micro-framework for pythonpychromecast
: version 14.0.1 needs Python 3.11+requests
: used to get media content-type from urlwaitress
: default server, optional, you can use another server
- Run
chromecast_control.py
:
usage: chromecast_control.py [-h]
[--server SERVER] [--host HOST] [--port PORT] [--open]
[--under UNDER] [--home HOME] [--static STATIC] [--partial PARTIAL] [--disable]
An HTTP server to control Chromecast & cast local media
options:
-h, --help show this help message and exit
--server SERVER server to use (default: waitress)
--host HOST address to bind to (default: 0.0.0.0)
--port PORT port to bind to (default: 8080)
--open open browser (default: no)
--under UNDER limit access under path (default: no limit)
--home HOME home path (default: user's home dir)
--static STATIC max static file size (default: 16MiB)
--partial PARTIAL default range length (default: 4MiB)
--disable disable streaming server (default: no)
- It would print something like this, visit the "internal IP URL":
Listen on: http://0.0.0.0:8080
Local URL: http://localhost:8080
Internal IP URL: http://192.168.XXX.XXX:8080
- Wait until the search is done, then select a chromecast to connect to.
- Click the "Cast" button.
- Paste media URL to cast; or click the "File" button to browse local files.
- In the file explorer, you can navigate and filter. Click a file to cast.
- Left / Space / Right: seek -10s / pause,play / seek +10s
- P / S / N: previous / stop / next
- M / Down / Up: mute / volume down / volume up
I wrote Dockerfile
.
I guess it would work, but it's never tested.
- Main UI
- Cast UI
- File Explorer
streaming_server.py
and file_explorer.tpl
form a simple HTTP server
which supports streaming (HTTP range requests, 206 Partial Content).
You can run it on your computer, and access files on another device within same LAN.
chromecast_control.py
and chromecast_control.html
form a Chromecast controller.
chromecast_control.html
gets chromecast status every 500ms, and updates the UI.
- better front-end
- icons?
- avoid changing input values when user interacting
- remember status & check some preconditions?
- better theme?
- better layout?
- more testing