Magnific-Popup icon indicating copy to clipboard operation
Magnific-Popup copied to clipboard

popup on a video tag directly

Open amir-rahnama opened this issue 10 years ago • 4 comments

If you wanna build the popup on top of a HTML5 native video element, is there a way to do this?

The following inline style is NOT working:

$('button').magnificPopup({
    items: {
        src: '<video class="white-popup" src="' + this.video_source + '"></video>',
        type: 'inline'
    }
});

amir-rahnama avatar Feb 08 '15 15:02 amir-rahnama

@ambodi, did you ever get this to work?

mhulse avatar Apr 01 '15 17:04 mhulse

@ambodi, did you ever get this to work?

For future readers, here's how I was able to get it to work:

JavaScript:

$('#foo').magnificPopup({
    delegate: 'a',
    type: 'inline',
    callbacks: {
        open: function() {

            // https://github.com/dimsemenov/Magnific-Popup/issues/125
            $('html').css('margin-right', 0);

            // Play video on open:
            $(this.content).find('video')[0].play();

        },
        close: function() {

            // Reset video on close:
            $(this.content).find('video')[0].load();

        }
    }
});

HTML:

<div id="video-01" class="video-popup mfp-hide">
    <video preload="auto" poster="../../videos/01.png">
        <source src="../../videos/01.mp4" type="video/mp4">
    </video>
</div> <!-- /#video-01 -->

CSS is up to you.

Seems to work pretty good to me.

mhulse avatar Apr 07 '15 19:04 mhulse

thx, it works for me ;)

sovanna avatar Aug 27 '15 11:08 sovanna

image i got this how to solve this?

Mikdadali avatar Mar 06 '20 12:03 Mikdadali