Skip to content

Commit

Permalink
Improve autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Jan 13, 2020
1 parent 8c753f9 commit 15979fe
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions view/include/embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,31 @@
//$(".vjs-big-play-button").hide();
$(".vjs-control-bar").css("opacity: 1; visibility: visible;");
if (typeof player === 'undefined') {
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
}
player.ready(function () {
<?php
if ($config->getAutoplay()) {
echo "setTimeout(function () { if(typeof player === 'undefined'){ player = videojs('mainVideo'".PlayerSkins::getDataSetup().");} player.play(); }, 150);";
echo "setTimeout(function () { if(typeof player === 'undefined'){ player = videojs('mainVideo'" . PlayerSkins::getDataSetup() . ");} player.play(); }, 150);";
} else {
?>
if (Cookies.get('autoplay') && Cookies.get('autoplay') !== 'false') {
setTimeout(function () {
if (typeof player === 'undefined') {
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
}
player.play();
var promise = player.play();

if (promise !== undefined) {
promise.then(_ => {
// Autoplay started!
}).catch(error => {
// Show something in the UI that the video is muted
player.muted(true);
player.play();
});
}

}, 150);
}
<?php } ?>
Expand Down

0 comments on commit 15979fe

Please sign in to comment.