]> _ Git - fluidbook-html5.git/commitdiff
wait #4435 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Apr 2021 11:16:43 +0000 (13:16 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Apr 2021 11:16:43 +0000 (13:16 +0200)
js/libs/fluidbook/fluidbook.video.js
js/libs/fluidbook/links/fluidbook.links.zoom.js

index 9ceb46003a886e1118c058b0a1e6fa0797657822..5b803eee2e8a6b345e8cf75a30d54674253ef323 100644 (file)
@@ -99,10 +99,11 @@ FluidbookVideo.prototype = {
             width = parseFloat($(e).data('width')),
             height = parseFloat($(e).data('height')),
             name = $(e).data('name'),
-            controls = $(e).data('controls'),
-            loop = $(e).data('loop'),
-            sound = $(e).data('sound'),
-            autoplay = $(e).data('autoplay'),
+            controls = parseInt($(e).data('controls')) == 1,
+            loop = parseInt($(e).data('loop')) == 1,
+            sound = parseInt($(e).data('sound')) == 1,
+            autoplay = parseInt($(e).data('autoplay')) == 1,
+            nativeAutoplay = !autoplay && parseInt($(e).data('nativeautoplay')) == 1,
             setup = $(e).data('setup'),
             linkid = $(e).data('link-id'),
             url = $(e).data('url'),
@@ -110,7 +111,7 @@ FluidbookVideo.prototype = {
             poster,
             html,
             player;
-        var hidelinksonplay = $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(',');
+        var hidelinksonplay = $(e).data('hidelinksonplay') == undefined || $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(',');
 
         //console.log('Initialising video ID: ' + id);
 
@@ -148,7 +149,7 @@ FluidbookVideo.prototype = {
         html = '<video class="video-js vjs-fluidbook-skin"';
         html += ' style="background-color:' + backgroundColor + ';" '
 
-        if (poster && autoplay != '1') {
+        if (poster && !autoplay) {
             html += 'poster="' + poster + '" ';
         }
 
@@ -163,18 +164,21 @@ FluidbookVideo.prototype = {
             html += 'height="' + height + '" ';
         }
 
-        if (controls == '1') {
+        if (controls) {
             html += 'controls ';
         } else {
             html += 'disablePictureInPicture ';
         }
 
-        if (loop == '1') {
+        if (loop) {
             //html += 'onended="this.play()" ';
             html += 'loop ';
         }
+        if (nativeAutoplay) {
+            html += 'autoplay ';
+        }
 
-        if (sound == '0') {
+        if (!sound) {
             html += 'muted ';
         }
 
@@ -211,13 +215,16 @@ FluidbookVideo.prototype = {
 
             $this.resizeControls(); // Make sure player controls are the right size
 
-            if(autoplay=='1') {
+            console.log('autoplay', autoplay);
+            if (autoplay) {
                 var promise = player.play();
 
                 if (promise !== undefined) {
                     promise.then(function () {
+                        console.log('autoplay ok');
                         // Autoplay started!
                     }).catch(function (error) {
+                        console.log('autoplay nok');
                         // Autoplay was prevented.
                     });
                 }
@@ -246,14 +253,11 @@ FluidbookVideo.prototype = {
                 player.one('play', function () {
                     //console.log('Player has started playing... ID: ' + id);
                     // Handle pause in here if needed.. Better than using the timeout...
-
                     if (settings.paused) {
-                        //console.log(id + ' should be paused');
                         setTimeout(function () {
                             player.pause();
                         }, 100);
                     } else {
-                        console.log('hide ', hidelinksonplay);
                         $.each(hidelinksonplay, function (k, id) {
                             $this.fluidbook.links.hideLinkById(id);
                         });
index 875e6fd3afa64bec52cbcb51247a2bca5804c7d9..64997460a45f866406b92ec38a4c5ed35aa3b895 100644 (file)
@@ -226,7 +226,7 @@ FluidbookLinksZoom.prototype = {
                                 menu += ' data-multimedia="' + encodeURIComponent(markup) + '"';
                             } else {
                                 menu += ' href="#/video/' + hash + '" ';
-                                var markup = ' <div class="videoContainer" data-loop="1" data-controls="0" data-sound="0" data-autoplay="1" width="1920" height="1080" data-name="' + data + '" data-id="vi_' + hash + '" id="vi_' + hash + '" data-link-id="v_' + hash + '"></div>';
+                                var markup = ' <div class="videoContainer" data-loop="1" data-controls="0" data-sound="0" data-nativeautoplay="1" width="1920" data-name="' + data + '" data-id="vi_' + hash + '" id="vi_' + hash + '" data-link-id="v_' + hash + '"></div>';
                                 menu += ' data-video="' + encodeURIComponent(markup) + '"';
                             }