Use Video.js player

This commit is contained in:
pluja 2020-08-16 16:45:13 +02:00
parent 382c8cb981
commit cc588e7108
5 changed files with 60015 additions and 6 deletions

View File

@ -320,7 +320,6 @@ def video(id):
'author':data['uploader'], 'author':data['uploader'],
'authorUrl':data['uploader_url'], 'authorUrl':data['uploader_url'],
'id':id, 'id':id,
'url': data['formats'][-1]['url'],
'averageRating': str((float(data['average_rating'])/5)*100) 'averageRating': str((float(data['average_rating'])/5)*100)
} }
return render_template("video.html", video=video) return render_template("video.html", video=video)
@ -330,8 +329,8 @@ def video(id):
def watch(id): def watch(id):
ydl = YoutubeDL() ydl = YoutubeDL()
data = ydl.extract_info("{id}".format(id=id), download=False) data = ydl.extract_info("{id}".format(id=id), download=False)
req = requests.get(data['formats'][-1]['url'], stream = True) req = requests.get(data['formats'][-2]['url'], stream = True)
return Response(stream_with_context(req.iter_content(chunk_size=1024)), content_type = req.headers['content-type']) return Response(stream_with_context(req.iter_content(chunk_size=4096)), content_type = req.headers['content-type'])
######################### #########################

1663
app/static/videojs.css Normal file

File diff suppressed because one or more lines are too long

58346
app/static/videojs.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
{% endif %} {% endif %}
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='semantic/semantic.min.css') }}"> <link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='semantic/semantic.min.css') }}">
<link rel="stylesheet" type= "text/css" href="{{ url_for('static',filename='styles.css') }}"> <link rel="stylesheet" type= "text/css" href="{{ url_for('static',filename='styles.css') }}">
<link rel="stylesheet" type= "text/css" href="{{ url_for('static',filename='videojs.css') }}">
</head> </head>
<body> <body>
<div class="ui stackable menu"> <div class="ui stackable menu">
@ -48,6 +49,7 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="{{ url_for('static',filename='videojs.js') }}"></script>
</body> </body>
</html> </html>

View File

@ -2,9 +2,8 @@
{% block content %} {% block content %}
<div style="margin-top: 2em;" class="ui one column centered grid"> <div style="margin-top: 2em;" class="ui one column centered grid">
<video width="720" height="480" controls> <video class="video-js vjs-default-skin" controls data-setup='{ "playbackRates": [0.5, 1, 1.25,1.5, 2] }' width="720" height="420" data-setup="{}">
<source src="/watch/{{video.id}}" type="video/mp4"> <source src="/watch/{{video.id}}" type="video/mp4">
<track label="English" kind="subtitles" srclang="en" src="captions/vtt/sintel-en.vtt" default>
</video> </video>
</div> </div>