From 95b39b7bd8431d36067c706d1e6c8cd877db5ae0 Mon Sep 17 00:00:00 2001 From: ninya9k Date: Tue, 6 Jul 2021 10:09:06 +0000 Subject: [PATCH] look cool when the stream is offline --- website/routes.py | 4 +++- website/static/platform.css | 28 +++++++++++++++++++++++++++- website/static/platform.js | 6 +++++- website/templates/index.html | 6 ++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/website/routes.py b/website/routes.py index 6e7daa4..64f57c8 100644 --- a/website/routes.py +++ b/website/routes.py @@ -37,12 +37,14 @@ def index(token=None): except KeyError: pass use_videojs = bool(request.args.get('videojs', default=int(VIDEOJS_ENABLED_BY_DEFAULT), type=int)) + online = stream.is_online() viewership.made_request(token) response = render_template('index.html', token=token, use_videojs=use_videojs, - start_number=resolve_segment_offset() if stream.is_online() else 0, + online=online, + start_number=resolve_segment_offset() if online else 0, hls_time=CONFIG['stream']['hls_time']) response = Response(response) # TODO: add a view of the chat only, either as an arg here or another route response.set_cookie('token', token) diff --git a/website/static/platform.css b/website/static/platform.css index bd7cd66..5ca9b76 100644 --- a/website/static/platform.css +++ b/website/static/platform.css @@ -13,12 +13,38 @@ position: relative; padding-bottom: calc(100% * 9 / 16); } -#stream video, #videojs { +#stream > video, #videojs, #offline { position: absolute; top: 0; left: 0; width: 100%; height: 100%; + overflow: hidden; +} +#offline > div:last-child { + position: absolute; + top: calc(50% - 0.607em); + width: 100%; + text-align: center; + font-weight: bold; + font-size: 400%; + text-shadow: 0 0 8px #000,0 0 128px #000; +} +#offline > div:first-child { + background-image: url("/static/noise.png"); + height: 100%; + width: 100%; + animation: noise-x 7s steps(14) infinite, noise-y 11s linear infinite; + background-size: cover; + filter: blur(2px) brightness(40%) contrast(70%); +} +@keyframes noise-x { + 0% {background-position-x: 0%;} + 100% {background-position-x: 100%;} +} +@keyframes noise-y { + 0% {background-position-y: 0%;} + 100% {background-position-y: 100%;} } #chat-border { diff --git a/website/static/platform.js b/website/static/platform.js index bbc69f5..0929c41 100644 --- a/website/static/platform.js +++ b/website/static/platform.js @@ -12,7 +12,11 @@ const videojsEnabled = parseInt(document.getElementById("videojs-enabled").value let firstSegment; if ( !videojsEnabled ) { - firstSegment = parseInt(/segment=(\d+)/.exec(video.src)[1]); + try { + firstSegment = parseInt(/segment=(\d+)/.exec(video.src)[1]); + } catch ( error ) { + firstSegment = null; // happens when the stream is offline + } } let token, streamTitle, viewerCount, streamStatus, streamLight, refreshButton, radialLoader; diff --git a/website/templates/index.html b/website/templates/index.html index f8c7c2d..de7ac66 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -62,6 +62,7 @@
+ {% if online %} {% if use_videojs %} @@ -75,6 +76,11 @@ {% endif %} + {% else %} + + +
OFFLINE
+ {% endif %}