A simple Python server with web UI to control Chromecast, play local media files via Chromecast.
- Python 3.4+, because this project uses the pychromecast library. (I think that is okay since Python2.7 will be dead after January 1, 2020)
- pychromecast installed (just run
pip install pychromecast
) - bottle installed (just run
pip install bottle
) - (Optional) Search and download some icons, see below.
First, some one-time configuration is needed:
- Configure the
home_path
variable inBottlePartialContent.py
as it is used to redirect from the root of the server. (Or you'll have to type the path you want manually each time you run this) - Configure the
DEVICE_FRIENDLY_NAME
variable inChromeCastControl.py
. Just type your Chromecast's name. (It depends on your Chromecast's settings. It may be something like "living room" or "客廳".) This is used to search your Chromecast. - Configure the
PORT
variable inMain.py
. (Or just use the default 8080) This is the port you'll connect.
Then, everytime you run you just:
- Make sure your computer and Chromecast are in the same network. (Same Wi-fi, basically.)
- Run
Main.py
. It'll search your Chromecast, then press enter to open the browser. - Enjoy the powerful Chromecast controller and player.
BottlePartialContent.py
and BottlePartialContentDirView.tpl
form a simple HTTP server which
supports streaming(partial content, the 206
HTTP status code).
You can run it on your computer, and watch the video in it on your cellphone!
ChromeCastControl.py
and ChromeCastControl.html
form a Chromecast controller,
a simple web interface to control Chromecast.
Main.py
combines these two independent scripts, forms an app which lets you
play the videos in your computer. The former hosts the file, and the latter tells Chromecast where
to play the video.
On which platforms can I run this?
Basically every platforms with Python 3.4+.
Though I only tested on Windows, Android Qpython3 and Termux.
There are browser opening features for PC / sl4a / Termux in Main.py
.
Why the icon
folder is empty?
I don't own any icons. I'm afraid that there would be copyright issues if I upload them.
The icons' filenames used in ChromeCastControl.html
are:
10sec_backward-512.png
10sec_forward-512.png
minus.png
pause.png
play.png
plus.png
rewind.png
stop.png
volOFF.png
volON.png
If you use icons, it'll be much prettier(I don't own the icons, this is just an example):
- The code is messy; clean it!
- It prints some exceptions; fix it! (But I haven't encountered any bugs / unexpected exiting. The program runs smoothly.)