使用 jQuery 隐藏时暂停 Vimeo 通用嵌入 [英] Pause Vimeo universal embed when hidden using jQuery

查看:23
本文介绍了使用 jQuery 隐藏时暂停 Vimeo 通用嵌入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上隐藏了一个 Vimeo 视频(通过通用嵌入 iframe).单击链接将其淡入,并单击视频外部(灯箱样式)将其淡出并隐藏 - 但视频会继续播放.我在 .

JS

player=$f(document.getElementById('tide'));//你也可以使用jquery:$('#tide')[0]player.api('暂停');

烦人的简单.这是一个 jsfiddle.net 上的示例.

I have a Vimeo video (via universal embed iframe) hidden on my page. Clicking a link fades it in, and clicking outside of the video (lightbox-style) fades it out and hides it - but the video keeps playing. I read on Vimeo's API that you can use JSON objects to pause the video, but I don't understand what they're saying.

HTML:

<img id="show_tide" class="vid" src"#">
<i<iframe id="tide" class="vim" src="http://player.vimeo.com/video/1747304?portrait=0&amp;color=ffffffapi=1" width="726" height="409" frameborder="0"></iframe>

JavaScript:

$('#underlay').click(function() {
    //pause VISIBLE (there are multiple) Vimeo video via API
    $('.vim, #underlay').fadeOut(400);
});

解决方案

You need to add from one of the froogaloop libraries.

JS

player=$f(document.getElementById('tide'));// you can use jquery too: $('#tide')[0] 
player.api('pause');

Annoyingly simple. Here's an example on jsfiddle.net.

这篇关于使用 jQuery 隐藏时暂停 Vimeo 通用嵌入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆