From 40da417ba14546e87d68722950c1bd9ed0e00c76 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 26 Nov 2024 18:45:07 +0100 Subject: [PATCH] wait #7211 @1 --- js/libs/fluidbook/fluidbook.video.js | 32 ++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index 7adfbb50..13be9a80 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -111,6 +111,7 @@ FluidbookVideo.prototype = { sound = parseInt($(e).data('sound')) == 1, autoplay = parseInt($(e).data('autoplay')) == 1, nativeAutoplay = !autoplay && parseInt($(e).data('nativeautoplay')) == 1, + repeat = parseInt($(e).data('repeat')), statsName = $(e).data('stats-name'), statsType = $(e).data('stats-type'), setup = $(e).data('setup'), @@ -120,6 +121,12 @@ FluidbookVideo.prototype = { poster, html, player; + + if (repeat === 0) { + loop = false; + } + + var hidelinksonplay = $(e).data('hidelinksonplay') == undefined || $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(','); // console.log('Initialising video ID: ' + id, statsType, statsName); @@ -179,7 +186,10 @@ FluidbookVideo.prototype = { html += 'disablePictureInPicture '; } - if (loop) { + console.log(loop,repeat); + + // If repeat is set, loop is not executed natively + if (loop && repeat === -1) { //html += 'onended="this.play()" '; html += 'loop '; } @@ -228,9 +238,6 @@ FluidbookVideo.prototype = { player = videojs(id, setup); player.ready(function () { - //console.log(id + ' player is ready'); - - $this.fluidbook.stats.trackEvent(statsType, 'show', statsName); $this.resizeControls(); // Make sure player controls are the right size @@ -289,6 +296,23 @@ FluidbookVideo.prototype = { } }); + if (repeat >= 0 && loop) { + let repeatCount = repeat + 1; + + player.on('ended', function () { + console.log('ended', repeatCount, player); + if (repeatCount === 0) { + player.pause(); + return; + } else { + console.log(player); + player.currentTime(0); + player.play(); + } + repeatCount--; + }); + } + player.play(); // Start player to go to current position - necessary even if it will be paused immediately if (settings.paused) { -- 2.39.5