鼠标悬停时播放 vimeo 视频,鼠标移出时暂停
我有一个页面,其中包含多个 vimeo 视频,以标准 iframe 方式嵌入。我在 HTML 头和 jquery (v 1.4.2) 中引用了 froogaloop.js (http://a.vimeocdn.com/js/froogaloop2.min.js)。我想要做的是能够在鼠标悬停时播放每个视频并在鼠标移出时暂停。
我在这里设置了一个 JSFiddle 页面: http://jsfiddle.net/g2Z2B/ 其中显示了我的内容我想做的 - 本质上只是将视频播放/暂停绑定到 jquery onmouseover/onmouseout 事件 - 但无论我读了多少 API 文档,我都无法让任何东西发挥作用。我尝试在这里拆开 API 演示页面: http://player.vimeo.com/playground但甚至无法让它在鼠标悬停时工作 - 而且每当我尝试删除不需要的东西时它也会破坏。我想做的只是一些非常简单的事情。
如果有人能在这里指出正确的方向,我将不胜感激!
I have a page which contains several vimeo videos, embedded in the standard iframe way. I have a reference to froogaloop.js (http://a.vimeocdn.com/js/froogaloop2.min.js) in the HTML head and also jquery (v 1.4.2). What I want to do is to be able to play each video onmouseover and pause onmouseout.
I've set up a JSFiddle page here: http://jsfiddle.net/g2Z2B/ which shows what I'm wanting to do - essentially just bind the video play/pause to the jquery onmouseover/onmouseout events - but no matter how much I read through the API documentation I just can't get anything to work. I've tried pulling apart the API demo page here: http://player.vimeo.com/playground but can't even get that to work on mouseover - plus whenever I try to strip out the unwanted stuff it breaks too. All I'm looking to do is something mega-simple.
If anyone could point me in the right direction here I'd be most grateful!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,第一件事是您应该使用 Froogaloop 的自定义
$f
选择器来抓取播放器。如果您查看playground.html
,这是在第 223 行完成的:此外,您应该调用
.api('play')
而不仅仅是('play ')
。完整的代码可能如下所示:固定小提琴:
http://jsfiddle.net/g2Z2B/1/
So the first thing is that you should be grabbing the player with Froogaloop's custom
$f
selector. If you look atplayground.html
this is done on line 223:Additionally, you should be calling
.api('play')
rather than just('play')
. Complete code might look something like this:Fixed fiddle:
http://jsfiddle.net/g2Z2B/1/