diff --git a/chapters.py b/chapters.py index 44d37e4cf8d8f1c56fd919d284b399b709b834b1..5eb22d3aa515ddc886b51b027cba1611bed8e419 100644 --- a/chapters.py +++ b/chapters.py @@ -1,3 +1,4 @@ +import json from server import * @app.route('/internal/newchapter/<int:lectureid>', methods=['POST', 'GET']) @@ -31,4 +32,6 @@ def chapters(lectureid): c['start'] = c['time'] c['end'] = last['start'] if last else 9999 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'}) diff --git a/templates/base.html b/templates/base.html index 4ac3bad76935eb1eaaa4257b52d2f7bf24e4f486..31bdd63c5df108ddf0271eab367dd16c295d5128 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,6 +18,7 @@ <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" 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')}}"> <script src="{{url_for('static', filename='jquery.js')}}"></script> @@ -33,6 +34,7 @@ <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.hotkeys.js')}}"></script> + <script src="{{url_for('static', filename='videojs/videojs-markers.js')}}"></script> {% endblock %} </head> <body> diff --git a/templates/macros.html b/templates/macros.html index 7ea20683593d918a5e879e0ef6f0489c62ab7c11..1cd7cff5f40c699a3beff0c9dd26bca2adee2db0 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -97,6 +97,25 @@ $(function() { videojs("videoplayer").createModal('',{"uncloseable": true }).contentEl().innerHTML='<div class="hidden-print alert alert-danger" role="alert">{{ msg|safe }}</div>'; {% 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> {% endmacro %}