Hello,
Kirby 3 does not permit autoplay for embedded videos. I read an older entry about it. Is there anyway to get around this problem? It is very vital for me. I am building a site with around 30 films.
I am using the js code below. The video modal window opens up in Kirby but does not autoplay.
I would really appreciate your help.
Best,
Nedim
indent preformatted text by 4 spaces| Remodal [video lightbox]
-----------------------------------------------*/
spUtils.$document.ready(function () {
var $videoModals = $('.video-modal');
if ($videoModals.length) {
spUtils.$body.after("\n <div id='videoModal' class='remodal remodal-video'>\n <button data-remodal-action='close' class='remodal-close'></button>\n <div class='embed-responsive embed-responsive-16by9'>\n <div id='videoModalIframeWrapper'></div>\n </div>\n </div>\n ");
var $videoModal = $('#videoModal').remodal();
var $videoModalIframeWrapper = $('#videoModalIframeWrapper');
$videoModals.each(function (index, value) {
$(value).on('click', function (e) {
e.preventDefault();
var $this = $(e.currentTarget);
var ytId = $this.attr('href').split('/');
var start = $this.data('start');
var end = $this.data('end');
if (ytId[2] === 'www.youtube.com') {
$videoModalIframeWrapper.html("<iframe id='videoModalIframe' src='//www.youtube.com/embed/" + ytId[3].split('?v=')[1] + "?rel=0&autoplay=1&enablejsapi=0&start=" + start + "&end=" + end + "' allowfullscreen' frameborder='0' class='embed-responsive-item hide'></iframe>");
} else if (ytId[2] === 'vimeo.com') {
$videoModalIframeWrapper.html("<iframe id='videoModalIframe' src='https://player.vimeo.com/video/" + ytId[3] + "?autoplay=1&title=0&byline=0&portrait=0 ?autoplay=1&title=0&byline=0&portrait=0 hide'></iframe>");
}
$videoModal.open();
});
});
spUtils.$document.on('closed', '.remodal', function (e) {
var $this = $(e.currentTarget);
if ($this.attr('id') === 'videoModal') {
$videoModalIframeWrapper.html('');
}
});
}
});