dimsemenov/Magnific-Popup

Take control of each vimeo video under a Magnific-Popup gallery.

rashed-jitu opened this issue · 0 comments

Hi, I want to take control on my each vimeo video currently it is playing under the popup iframe.
I have tried this it not working properly.

$('.selector).magnificPopup({
            type: "iframe",
            gallery: {
                enabled: true
            },
            iframe: {
                patterns: {
                    vimeo: {
                        index: 'vimeo.com/',
                        id: '/',
                        src: '//player.vimeo.com/video/%id%?autoplay=1&api=1&player_id=playall'
                    },
                }
            },
            callbacks: {
                change: function () {
                    var tryingNumber = 15;
                    var tried = 0;
                    var instance = this;
                    var element = [];
                    setTimeout(function tryToGetIframe() {
                        element = $('.mfp-iframe');
                        if (!element.length && tryingNumber > tried) {
                            tried++;
                            setTimeout(tryToGetIframe, 5000);
                        } else if (element.length) {
                            var player = new Vimeo.Player(element);
                            player.on('ended', function () {
                                console.log('ended');
                                instance.next();
                            })
                        }
                    }, 5000)
                }
            }
        });

Its works for the first item okay. but for next items it does not work.