@
@
@erstet2015-03-15 14:54:20
JavaScript
@erstet, 2015-03-15 14:54:20

FancyBox + YouTube AutoPlay?

Good day, dear toasters), there is such a problem with a site with wordpress + ninja popup plugin installed, I display a video in the youtube frame with automatic playback, everything works fine, only when the fancybox modal window is closed, the video continues to play, I have already rummaged through everything, not strong in js, but I suspect that it is necessary to carry out some actions with vid.attr('src', ''), with the OnClose action or something like that (or maybe not at all), in general, I can’t understand the second day what to do (((
Ninja popup uses fancyBox -jQuery Plugin * version: 2.1.4
If you need to throw off the script, I really need help, thanks in advance to everyone who responds.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Goryachkin, 2015-03-15
_

If the video is displayed through an iframe, then you can do this:

$(document).ready(function () {
    var close = function() {
        var player = $('iframe'), video = player.attr("src");
        player.attr("src","");
        player.attr("src", video);
    }
   $(document).on('click', '.fancybox-close', function () {
         close();
   });
});

Here this f-yu also launch on onClose. Accordingly, #player is the id of the iframe.
If HTML5, then you can do this:
function close() {
    $('#player').get(0).stopVideo();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question