]> _ Git - fluidbook-html5.git/commitdiff
wait #7211 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Nov 2024 17:45:07 +0000 (18:45 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Nov 2024 17:45:07 +0000 (18:45 +0100)
js/libs/fluidbook/fluidbook.video.js

index 7adfbb508aac5da9731dc30eecec80a8d0065d97..13be9a804f67848336878d99c6448e37ca4d63f5 100644 (file)
@@ -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) {