使用 jQuery 隐藏时暂停 Vimeo 通用嵌入
我的页面上隐藏了一个 Vimeo 视频(通过通用嵌入 iframe)。单击链接会将其淡入,单击视频外部(灯箱样式)会将其淡出并隐藏 - 但视频会继续播放。我在 Vimeo 的 API 上读到您可以使用 JSON 对象来暂停视频,但我不明白他们在说什么。
HTML:
<img id="show_tide" class="vid" src"#">
<i<iframe id="tide" class="vim" src="http://player.vimeo.com/video/1747304?portrait=0&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);
});
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&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);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要从 froogaloop 库 之一进行添加。
JS
简单得令人烦恼。这是jsfiddle.net 上的示例。
You need to add from one of the froogaloop libraries.
JS
Annoyingly simple. Here's an example on jsfiddle.net.
我想添加一个像这样的播放/暂停按钮,而不使用 jquery 或 froogaloop。我不知道为什么,但是,我讨厌在不必要的时候包含一个图书馆。尤其是对于像这样简单的事情。
这是我想到的(我只是将其发布给其他正在搜索的人):
I wanted to add a play/pause button like this without using jquery or froogaloop. I don't know why but, I hate including a library when I don't have to. Especially for simple things like this.
Here's what I came up with (I'm just posting this for other people who are searching) :
这是一种使用 froogaloop 库从外部 HTML 元素暂停 Vimeo 视频的简单方法,对我有用:
Here's a simple way to pause a Vimeo video from an external HTML element that worked for me, using the froogaloop libray:
我参加聚会有点晚了,但我必须加载 froogaloop、jquery 和 Vimeo API。
请务必将
?api=1&player_id='frame'
附加到嵌入视频链接的末尾我的代码看起来像这样
I'm a little late to the party, but I had to load froogaloop, jquery, and the Vimeo API also.
be sure to append
?api=1&player_id='frame'
to the end of your embedded video linkMy code looked something like this after