From 55be3fb90255847ae97a198e53294aff14121679 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Mon, 1 May 2017 23:14:08 +0200 Subject: [PATCH] Added timeline chapters markers --- chapters.py | 3 +++ templates/base.html | 2 ++ templates/macros.html | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/chapters.py b/chapters.py index 44d37e4..5eb22d3 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 4ac3bad..31bdd63 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 7ea2068..1cd7cff 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 %} -- GitLab