E
E
Erling2016-02-28 17:33:50
YouTube
Erling, 2016-02-28 17:33:50

How to launch a Youtube video when opening a popup with it?

The task when opening a jQuery popup (with the YouTube player code, which is stored at the end of the page) is to play the video . Those. so as not to click on Play again in the popup. How to implement this, knowledgeable tell me please?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Nikolaev, 2016-02-28
@Erling

Add the parameter autoplay=1 to the video link. For example:
Some plugins can do this for you, but here you need to look at the documentation for the plugin you are using.

K
kos88, 2017-11-22
@kos88

Add the enablejsapi=1 parameter to the iframe,
connect the script

$('.popupOpen').on('click', function(){		
    jQuery("iframe").each(function() {
      jQuery(this)[0].contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*')
    });		
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question