add chromecast button
This commit is contained in:
parent
5dd5390fac
commit
d8df3ac030
@ -1,6 +1,6 @@
|
|||||||
FROM alpine:edge as base
|
FROM alpine:edge as base
|
||||||
RUN ["apk", "add", "--no-cache", "py3-virtualenv"]
|
RUN ["apk", "add", "--no-cache", "py3-virtualenv"]
|
||||||
RUN ["mkdir", "-p", "/app"]
|
RUN ["mkdir", "-p", "/app/version"]
|
||||||
COPY ["tv.json", "/app/setup/tv.json"]
|
COPY ["tv.json", "/app/setup/tv.json"]
|
||||||
COPY ["backend/start.sh", "/app/start.sh"]
|
COPY ["backend/start.sh", "/app/start.sh"]
|
||||||
COPY ["backend/install.sh", "/app/setup/install.sh"]
|
COPY ["backend/install.sh", "/app/setup/install.sh"]
|
||||||
|
@ -38,14 +38,20 @@ try:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
else:
|
else:
|
||||||
with open("/app/chromecast-version.txt", "w") as f:
|
with open("/app/version/chromecast.txt", "w") as f:
|
||||||
f.write(chromecast_version)
|
f.write(chromecast_version)
|
||||||
|
|
||||||
|
def store_cdnjs(name):
|
||||||
|
version = None
|
||||||
try:
|
try:
|
||||||
resp = requests.get("https://api.cdnjs.com/libraries/video.js?fields=version")
|
resp = requests.get(f'https://api.cdnjs.com/libraries/{name}?fields=version')
|
||||||
data = json.loads(resp.text)
|
data = json.loads(resp.text)
|
||||||
videojs_version = data["version"]
|
version = data["version"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
else:
|
else:
|
||||||
with open("/app/videojs-version.txt", "w") as f:
|
with open(f'/app/version/{name}.txt', "w") as f:
|
||||||
f.write(videojs_version)
|
f.write(version)
|
||||||
|
|
||||||
|
store_cdnjs("video.js")
|
||||||
|
store_cdnjs("font-awesome")
|
||||||
|
@ -240,17 +240,19 @@ template_js = None
|
|||||||
template_embed = tornado.template.Template('<iframe src="{{ origin }}?provider={{ provider }}&render=true" width="{{ width }}" height="{{ height }}" allow="fullscreen"></iframe>')
|
template_embed = tornado.template.Template('<iframe src="{{ origin }}?provider={{ provider }}&render=true" width="{{ width }}" height="{{ height }}" allow="fullscreen"></iframe>')
|
||||||
|
|
||||||
videojs_version = None
|
videojs_version = None
|
||||||
castjs_version = None
|
font_awesome_version = None
|
||||||
custom_style = None
|
custom_style = None
|
||||||
try:
|
try:
|
||||||
with open("/app/index.html", "r") as f:
|
with open("/app/index.html", "r") as f:
|
||||||
template_html = tornado.template.Template(f.read().strip())
|
template_html = tornado.template.Template(f.read().strip())
|
||||||
with open("/app/script.js", "r") as f:
|
with open("/app/script.js", "r") as f:
|
||||||
template_js = tornado.template.Template(f.read().strip())
|
template_js = tornado.template.Template(f.read().strip())
|
||||||
with open("/app/videojs-version.txt", "r") as f:
|
with open("/app/version/video.js.txt", "r") as f:
|
||||||
videojs_version = f.read().strip()
|
videojs_version = f.read().strip()
|
||||||
with open("/app/chromecast-version.txt", "r") as f:
|
with open("/app/version/chromecast.txt", "r") as f:
|
||||||
chromecast_version = f.read().strip()
|
chromecast_version = f.read().strip()
|
||||||
|
with open("/app/version/font-awesome.txt", "r") as f:
|
||||||
|
font_awesome_version = f.read().strip()
|
||||||
with open("/app/style.css", "r") as f:
|
with open("/app/style.css", "r") as f:
|
||||||
custom_style_raw = bytes(f.read().strip(), "utf-8")
|
custom_style_raw = bytes(f.read().strip(), "utf-8")
|
||||||
b64 = str(base64.b64encode(custom_style_raw), "ascii")
|
b64 = str(base64.b64encode(custom_style_raw), "ascii")
|
||||||
@ -350,6 +352,7 @@ class MainHandler(tornado.web.RequestHandler):
|
|||||||
data["script"] = script
|
data["script"] = script
|
||||||
data["videojs_version"] = videojs_version
|
data["videojs_version"] = videojs_version
|
||||||
data["chromecast_version"] = chromecast_version
|
data["chromecast_version"] = chromecast_version
|
||||||
|
data["font_awesome_version"] = font_awesome_version
|
||||||
data["custom_style"] = custom_style
|
data["custom_style"] = custom_style
|
||||||
data["stream_url"] = handler.stream_url
|
data["stream_url"] = handler.stream_url
|
||||||
data["render_url"] = handler.render_url
|
data["render_url"] = handler.render_url
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<script async src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
<script async src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
||||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video.min.js"></script>
|
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video.min.js"></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ data["font_awesome_version"] }}/css/all.min.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video-js.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ data["videojs_version"] }}/video-js.css">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@{{ data["chromecast_version"] }}/dist/silvermine-videojs-chromecast.css">
|
||||||
<link rel="stylesheet" href="{{ data["custom_style"] }}">
|
<link rel="stylesheet" href="{{ data["custom_style"] }}">
|
||||||
|
@ -37,9 +37,23 @@
|
|||||||
source.type = ctype;
|
source.type = ctype;
|
||||||
source.src = upstream;
|
source.src = upstream;
|
||||||
player.src(source);
|
player.src(source);
|
||||||
|
let Button = videojs.getComponent("Button");
|
||||||
|
let cbutton = {};
|
||||||
|
cbutton.clickHandler = (ev) => {
|
||||||
|
videojs.log("clicked");
|
||||||
|
}
|
||||||
|
let button = new Button(player, cbutton);
|
||||||
|
button.addClass("fab");
|
||||||
|
button.addClass("fa-chromecast");
|
||||||
|
button.addClass("vjs-control");
|
||||||
|
button.addClass("vjs-button");
|
||||||
|
button.addClass("vjs-big-chromecast");
|
||||||
|
player.addChild(button);
|
||||||
|
player.one("play", (ev) => {
|
||||||
|
player.removeChild(button);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", handleCount);
|
document.addEventListener("DOMContentLoaded", handleCount);
|
||||||
xhr.addEventListener("load", handleCount);
|
xhr.addEventListener("load", handleCount);
|
||||||
})();
|
})();
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
.vjs-big-chromecast {
|
||||||
|
position: absolute !important;
|
||||||
|
font-size: 3rem !important;
|
||||||
|
height: 4rem !important;
|
||||||
|
width: 4rem !important;
|
||||||
|
top: 1rem !important;
|
||||||
|
right: 1rem !important;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user