Pause all Vimeo videos with API?

与世无争的帅哥 提交于 2019-12-06 08:17:28

I used this with jQuery:

<script type="text/javascript" src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
<script type="text/javascript">// <![CDATA[
function pauseAll() {
    $('iframe[src*="vimeo.com"]').each(function () {
        $f(this).api('pause');
    });
}
// ]]></script>

use it on an onclick.

<a href="#" onclick="pauseAll(); return false;">pause all</a>

You can use this code to pause all YouTube and Vimeo videos on the page:

$('iframe').each(function() {
  this.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
  this.contentWindow.postMessage('{"method":"pause","value":""}', '*');
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!