make videojs optional via ?videojs url argument

このコミットが含まれているのは:
n9k 2021-04-15 17:26:10 +00:00
コミット 84b60899fa
2個のファイルの変更12行の追加3行の削除

ファイルの表示

@ -32,8 +32,9 @@ def index(token=None):
viewership.video_was_corrupted.remove(token) viewership.video_was_corrupted.remove(token)
except KeyError: except KeyError:
pass pass
use_videojs = bool(request.args.get('videojs', default=1, type=int))
viewership.made_request(token) viewership.made_request(token)
response = Response(render_template('index.html', token=token)) # TODO: add a view of the chat only, either as an arg here or another route response = Response(render_template('index.html', token=token, use_videojs=use_videojs)) # TODO: add a view of the chat only, either as an arg here or another route
response.set_cookie('token', token) response.set_cookie('token', token)
return response return response

ファイルの表示

@ -2,20 +2,24 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- https://unpkg.com/video.js@7.12.1/dist/video-js.min.css -->
<link href="/static/external/video-js.min.css" rel="stylesheet">
<link href="/static/external/pure-min.css" rel="stylesheet"> <link href="/static/external/pure-min.css" rel="stylesheet">
<link href="/static/external/grids-responsive-min.css" rel="stylesheet"> <link href="/static/external/grids-responsive-min.css" rel="stylesheet">
<link href="/static/platform.css" rel="stylesheet"> <link href="/static/platform.css" rel="stylesheet">
{% if use_videojs %}
<!-- https://unpkg.com/video.js@7.12.1/dist/video-js.min.css -->
<link href="/static/external/video-js.min.css" rel="stylesheet">
<!-- https://unpkg.com/video.js@7.12.1/dist/video.min.js --> <!-- https://unpkg.com/video.js@7.12.1/dist/video.min.js -->
<script src="/static/external/video.min.js"></script> <script src="/static/external/video.min.js"></script>
<!-- https://unpkg.com/@videojs/http-streaming@2.7.1/dist/videojs-http-streaming.min.js --> <!-- https://unpkg.com/@videojs/http-streaming@2.7.1/dist/videojs-http-streaming.min.js -->
<script src="/static/external/videojs-http-streaming.min.js"></script> <script src="/static/external/videojs-http-streaming.min.js"></script>
{% endif %}
<noscript> <noscript>
<style> <style>
{% if use_videojs %}
#videojs { #videojs {
display: none; display: none;
} }
{% endif %}
#users-container { #users-container {
display: none; display: none;
} }
@ -44,6 +48,7 @@
<div class="pure-u-1 pure-u-md-2-3"> <div class="pure-u-1 pure-u-md-2-3">
<!-- TODO: choose which elements get borders more cleverly --> <!-- TODO: choose which elements get borders more cleverly -->
<div id="stream" class="border"> <div id="stream" class="border">
{% if use_videojs %}
<!-- https://stackoverflow.com/questions/41014197/how-can-i-play-a-m3u8-file-video-using-the-html5-video-element --> <!-- https://stackoverflow.com/questions/41014197/how-can-i-play-a-m3u8-file-video-using-the-html5-video-element -->
<video id="videojs" style="width: 100%;height: 100%;" class="video-js vjs-default-skin vjs-big-play-centered" data-setup='{"controls": true, "autoplay": true }'> <video id="videojs" style="width: 100%;height: 100%;" class="video-js vjs-default-skin vjs-big-play-centered" data-setup='{"controls": true, "autoplay": true }'>
<source src="{{ url_for('playlist', token=token) }}" type="application/x-mpegURL"> <source src="{{ url_for('playlist', token=token) }}" type="application/x-mpegURL">
@ -51,6 +56,9 @@
<noscript> <noscript>
<video style="width: 100%;height: 100%;" controls autoplay src="{{ url_for('segments', token=token) }}"> <video style="width: 100%;height: 100%;" controls autoplay src="{{ url_for('segments', token=token) }}">
</noscript> </noscript>
{% else %}
<video style="width: 100%;height: 100%;" controls autoplay src="{{ url_for('segments', token=token) }}">
{% endif %}
</div> </div>
<div id="stream-info-container"><noscript><iframe id="stream-info" src="{{ url_for('stream_info') }}?token={{ token }}&embed=1"></iframe></noscript></div> <div id="stream-info-container"><noscript><iframe id="stream-info" src="{{ url_for('stream_info') }}?token={{ token }}&embed=1"></iframe></noscript></div>
<div id="source" style="margin: -2.75em 0 1.5em 1.25em;"><a href="https://gitlab.com/ninya9k/onion-livestreaming" target="_blank">source code</a></div> <div id="source" style="margin: -2.75em 0 1.5em 1.25em;"><a href="https://gitlab.com/ninya9k/onion-livestreaming" target="_blank">source code</a></div>