To get videos to autoplay on Google and Safari
Thanks to @greggnakamura
$.extend( {
gnAutoplay : function( videoId ) {
var promise = document.getElementById(videoId).play();
if (promise !== undefined) {
promise
.then(_ => {
console.log('Autoplay started!');
})
.catch(error => {
unmuteButton.addEventListener('click', function() {
video.muted = false;
});
});
}
}
} );