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 f8bbc93 commit e73898e
Showing 1 changed file with 2 additions and 57 deletions.
59 changes: 2 additions & 57 deletions view/include/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,35 +171,7 @@
if (typeof player === 'undefined') {
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
}
try {
player.currentTime(<?php echo $currentTime; ?>);
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();
});
}
} catch (e) {
setTimeout(function () {
player.currentTime(<?php echo $currentTime; ?>);
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();
});
}
}, 1000);
}
playerPlay(<?php echo $currentTime; ?>);
}, 150);
<?php } else { ?>

Expand All @@ -215,34 +187,7 @@
if (typeof player === 'undefined') {
player = videojs('mainVideo'<?php echo PlayerSkins::getDataSetup(); ?>);
}
try {
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();
});
}
} catch (e) {
setTimeout(function () {
player.currentTime(<?php echo $currentTime; ?>);
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();
});
}
}, 1000);
}
playerPlay(<?php echo $currentTime; ?>);
}, 150);
}

Expand Down

0 comments on commit e73898e

Please sign in to comment.