首页 > 解决方案 > 如何为 Magnific Popup 自动播放视频

问题描述

嗨,

我正在使用 magnific popup。但我想为所有浏览器自动播放视频,当打开 magnific popup.see 我正在使用这个 js。

function magnificPopupFn() {
    $('.popup-vimeo').magnificPopup({
        type: 'iframe',
        mainClass: 'mfp-fade',
        removalDelay: 160,
        preloader: false,
        fixedContentPos: true,
        closeOnContentClick: false,
        closeBtnInside: true,
        closeOnBgClick: true,
        callbacks: {
            open: function() {
                $('html').css('margin-right', 0);
                $('body').addClass('noscroll');
                $('iframe').attr('allow', 'autoplay');
            },
            close: function() {
                $('body').removeClass('noscroll');
            }, 
        }
    });
}
magnificPopupFn();

标签: jquerywordpressmagnific-popup

解决方案


在“自动播放政策更改”之后,这不再可能,请参阅https://developers.google.com/web/updates/2017/09/autoplay-policy-changes


推荐阅读