]> _ Git - fluidbook-html5.git/commitdiff
wait #7229 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Dec 2024 17:01:45 +0000 (18:01 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Dec 2024 17:01:45 +0000 (18:01 +0100)
js/libs/fluidbook/fluidbook.video.js
js/libs/scorm/scorm.js

index dce78f4313a830b6fe654e28830eea650448474b..1f140d3d0dab5288e7b1a74cf32c496427c4e362 100644 (file)
@@ -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
index 164635270fef9c15cb5338af75c385f2f4c03b14..c690e4a9f63b228de21252d27ccc2d2d15cd2604 100644 (file)
@@ -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();
 }