-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappcast.py
39 lines (29 loc) · 858 Bytes
/
appcast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys
import time
import pychromecast
import pychromecast.controllers.dashcast as dashcast
# Chromecast friendly name
CAST_NAME = "The TV"
URL="http://192.168.1.6:3000"
chromecasts, browser = pychromecast.get_listed_chromecasts(
friendly_names=[CAST_NAME]
)
if not chromecasts:
print('No chromecast with name "{}" discovered'.format(CAST_NAME))
sys.exit(1)
cast = chromecasts[0]
# Start socket client's worker thread and wait for initial status update
cast.wait()
d = dashcast.DashCastController()
cast.register_handler(d)
if not cast.is_idle:
print("Killing current running app")
cast.quit_app()
t = 5
while cast.status.app_id is not None and t > 0:
time.sleep(0.1)
t = t - 0.1
d.load_url(URL)
#browser.stop_discovery()
time.sleep(2)
d.load_url(URL,callback_function=lambda result: d.load_url(URL))