使用API暂停所有Vimeo视频吗? [英] Pause all Vimeo videos with API?
问题描述
我碰壁了,无法弄清楚如何进行这项工作.使用Vimeo的Advanced API,我可以从带有缩略图的帐户中提取所有视频.单击缩略图时,视频将显示在上方,单击其他缩略图会隐藏当前显示的视频.问题是即使隐藏视频,视频仍会继续播放.我已经花了几个小时来查看API,但隐藏起来后却无法暂停.
I have hit a wall and cannot figure out how to make this work. With Vimeo's Advanced API I am pulling in all videos from an account with thumbnails. When clicking on a thumbnail the video is shown above and clicking on a different thumbnail hides the currently shown video. The problem is that the video continues to play even when it is hidden. I have spent a few hours looking at the API and I cannot get it to pause when hidden.
var iframe = $('.video')[0];
$('.thumbnail a').click(function(e) {
$f(iframe).api('pause');
});
以上代码仅暂停播放第一个视频.如果我将数字[0]更改为[1],则当您单击另一个缩略图时,第二个视频将暂停.有人有想法吗?我在上面的代码中使用了froogaloop.
The above code pauses only the first video. If I change the number [0] to [1], then the second video pauses when you click on another thumbnail. Does anyone have any thoughts? I am using froogaloop in the above code.
推荐答案
您可以使用以下代码暂停页面上的所有YouTube和Vimeo视频:
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":""}', '*');
});
这篇关于使用API暂停所有Vimeo视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!