From 9c3506699ed941e79c6837af482586397910356e Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Sat, 18 Feb 2017 13:03:12 +0100 Subject: [PATCH] closes #187 --- templates/macros.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/templates/macros.html b/templates/macros.html index 757ce31..6b1f0c0 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -55,6 +55,29 @@ $('#videoplayer').addClass("vjs-16-9"); $('#videoplayer').css("width"); $(function() { + //resume + var progress_key = "progress_{{ lecture.id }}"; + var seconds_played; + if (localStorage) { + seconds_played = localStorage.getItem(progress_key); + if (!seconds_played) { + seconds_played = 0; + } else { + videojs('videoplayer').currentTime(seconds_played); + } + } + videojs("videoplayer").on("timeupdate", function() { + if (localStorage) { + var player_cur_Time = Math.round(videojs("videoplayer").currentTime()); + if(Math.abs(player_cur_Time - seconds_played) >= 10) { + seconds_played = player_cur_Time; + localStorage.setItem( progress_key , seconds_played) + } + } + + }); + + //autoplay var playerplay = function() { if ($('#videoplayer').data("wasnotplayed") == 1) { videojs('videoplayer').play(); -- GitLab