Skip to content
Snippets Groups Projects
Commit 55be3fb9 authored by Julian Rother's avatar Julian Rother
Browse files

Added timeline chapters markers

parent f480b090
No related branches found
No related tags found
No related merge requests found
import json
from server import * from server import *
@app.route('/internal/newchapter/<int:lectureid>', methods=['POST', 'GET']) @app.route('/internal/newchapter/<int:lectureid>', methods=['POST', 'GET'])
...@@ -31,4 +32,6 @@ def chapters(lectureid): ...@@ -31,4 +32,6 @@ def chapters(lectureid):
c['start'] = c['time'] c['start'] = c['time']
c['end'] = last['start'] if last else 9999 c['end'] = last['start'] if last else 9999
last = c last = c
if 'json' in request.values:
return Response(json.dumps([{'time': c['time'], 'text': c['text']} for c in chapters]), mimetype='application/json')
return Response(render_template('chapters.srt',chapters=chapters), 200, {'Content-Type':'text/vtt'}) return Response(render_template('chapters.srt',chapters=chapters), 200, {'Content-Type':'text/vtt'})
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}"> <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
<link rel="stylesheet" href="{{url_for('static', filename='font-awesome/css/font-awesome.css')}}"> <link rel="stylesheet" href="{{url_for('static', filename='font-awesome/css/font-awesome.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/video-js.css')}}"> <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/video-js.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs.markers.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs-resolution-switcher.css')}}"> <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs-resolution-switcher.css')}}">
<script src="{{url_for('static', filename='jquery.js')}}"></script> <script src="{{url_for('static', filename='jquery.js')}}"></script>
...@@ -33,6 +34,7 @@ ...@@ -33,6 +34,7 @@
<script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js')}}"></script> <script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-contrib-hls.js')}}"></script> <script src="{{url_for('static', filename='videojs/videojs-contrib-hls.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs.hotkeys.js')}}"></script> <script src="{{url_for('static', filename='videojs/videojs.hotkeys.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-markers.js')}}"></script>
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
......
...@@ -97,6 +97,25 @@ $(function() { ...@@ -97,6 +97,25 @@ $(function() {
videojs("videoplayer").createModal('',{"uncloseable": true }).contentEl().innerHTML='<div class="hidden-print alert alert-danger" role="alert">{{ msg|safe }}</div>'; videojs("videoplayer").createModal('',{"uncloseable": true }).contentEl().innerHTML='<div class="hidden-print alert alert-danger" role="alert">{{ msg|safe }}</div>';
{% endfor %} {% endfor %}
//markers
$.ajax({method: "GET", url: "{{url_for('chapters',lectureid=lecture.id, json=1)}}", dataType: "json",
success: function (data) {
videojs("videoplayer").markers({
markerStyle: {
'width':'5px',
'border-radius': '40%',
'background-color': 'black'
},
markerTip:{
display: true,
text: function(marker) {
return marker.text;
}
},
markers: data});
}});
}); });
</script> </script>
{% endmacro %} {% endmacro %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment