From 5abe278aaccf1099c133e5f3c99e19d7a2093c80 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 12 Dec 2024 18:01:45 +0100 Subject: [PATCH] wait #7229 @2 --- js/libs/fluidbook/fluidbook.video.js | 19 +++++++++++++++++++ js/libs/scorm/scorm.js | 17 ++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index dce78f43..1f140d3d 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -457,6 +457,25 @@ FluidbookVideo.prototype = { this.pause(); }); }, + + hasOneVideoPlaying: function () { + let res = false; + $.each(this.getActivePlayers(), function (k, player) { + if (player.muted()) { + //return; + } + if (player.paused()) { + return; + } + if (player.volume() <= 0) { + //return; + } + res = true; + return true; + }); + return res; + }, + removeAllVideos: function (skipPopupVideos) { // Videos contained inside a popup #view element are in a separate section of the DOM diff --git a/js/libs/scorm/scorm.js b/js/libs/scorm/scorm.js index 16463527..c690e4a9 100644 --- a/js/libs/scorm/scorm.js +++ b/js/libs/scorm/scorm.js @@ -107,14 +107,23 @@ function initScormEvents() { finishScorm(); }); - $(document).on('mousemove touchmove', function () { - resetInactivityTimer(); + $(document).on('mousemove touchmove keydown', function () { + resetScormInactivityTimer(); startScormTimer(); }); + setInterval(function () { + console.log('check scorm timer'); + if (fluidbook.video.hasOneVideoPlaying()) { + console.log('video playing, reset inactivity timer'); + resetScormInactivityTimer(); + return; + } + let inactivity = Math.round(((new Date()).getTime() - SCORM_LAST_ACTIVITY) / 1000); if (inactivity > 15) { + console.log('inactivity detected'); pauseScormTimer(); } if (inactivity > 300) { @@ -124,10 +133,12 @@ function initScormEvents() { }, 10000); $(window).on('blur', function () { + console.log('window blur'); pauseScormTimer(); }); $(window).on('focus', function () { + console.log('window focus'); startScormTimer(); }); @@ -272,7 +283,7 @@ function pauseScormTimer() { SCORM_START_TIME = 0; } -function resetInactivityTimer() { +function resetScormInactivityTimer() { SCORM_LAST_ACTIVITY = new Date().getTime(); } -- 2.39.5