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
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) {
}, 10000);
$(window).on('blur', function () {
+ console.log('window blur');
pauseScormTimer();
});
$(window).on('focus', function () {
+ console.log('window focus');
startScormTimer();
});
SCORM_START_TIME = 0;
}
-function resetInactivityTimer() {
+function resetScormInactivityTimer() {
SCORM_LAST_ACTIVITY = new Date().getTime();
}