]> _ Git - fluidbook-html5.git/commitdiff
wait #4372 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 24 Mar 2021 17:58:35 +0000 (18:58 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 24 Mar 2021 17:58:35 +0000 (18:58 +0100)
js/libs/fluidbook/fluidbook.video.js

index 68d7d16023bed787d00c46a548906b0d744bc1de..5b382abbb46261475d459208d0d2b3f9b6f7604c 100644 (file)
@@ -173,9 +173,7 @@ FluidbookVideo.prototype = {
             //html += 'onended="this.play()" ';
             html += 'loop ';
         }
-        if (autoplay == '1') {
-            html += 'autoplay ';
-        }
+
         if (sound == '0') {
             html += 'muted ';
         }
@@ -259,19 +257,19 @@ FluidbookVideo.prototype = {
                 setTimeout(function () {
                     $this.fluidbook.contentlock.addAction(linkid, 'complete');
                 }, (player.duration() - 5) * 1000);
-
-                // var playPromise = player.play();
-                // if (settings.paused) {
-                //     if (playPromise && (typeof Promise !== 'undefined') && (playPromise instanceof Promise)) {
-                //             playPromise.then((result) => {
-                //                     setTimeout(player.pause, 100);
-                //             });
-                //     } else {
-                //             player.pause();
-                //     }
-                // }
+            }else{
+                if(autoplay=='1') {
+                    var promise = player.play();
+
+                    if (promise !== undefined) {
+                        promise.then(function () {
+                            // Autoplay started!
+                        }).catch(function (error) {
+                            // Autoplay was prevented.
+                        });
+                    }
+                }
             }
-
         });
 
         player.on('play', function () {
@@ -364,9 +362,7 @@ FluidbookVideo.prototype = {
         if (loop == '1') {
             html += 'onended="this.play()" ';
         }
-        if (autoplay == '1') {
-            html += 'autoplay="autoplay" ';
-        }
+        html += 'data-autoplay="' + autoplay + '" ';
         if (sound == '0') {
             html += 'muted="muted" ';
         }