From: Vincent Vanwaelscappel Date: Wed, 24 Mar 2021 17:58:35 +0000 (+0100) Subject: wait #4372 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=93eb183aa28b1e56bbb7c50eac2c2cb00b050e63;p=fluidbook-html5.git wait #4372 @1 --- diff --git a/js/libs/fluidbook/fluidbook.video.js b/js/libs/fluidbook/fluidbook.video.js index 68d7d160..5b382abb 100644 --- a/js/libs/fluidbook/fluidbook.video.js +++ b/js/libs/fluidbook/fluidbook.video.js @@ -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" '; }