Where does this pause vimeo embed code go in my slider script?

送分小仙女□ 提交于 2019-12-14 04:05:26

问题


I'm using coda slider to slide a number of embedded Vimeo videos into view and I now need each video to pause when a link to another slide has been clicked. I'm embedding videos using an iframe and found this code which does the trick: http://jsfiddle.net/ASa2K/4/

My code is different though and I just don't know where the following pause script goes in my Coda slider JS file:

$("iframe").each(function() {
            this.contentWindow.postMessage('{ "method": "pause" }', "http://player.vimeo.com");
});

I also know, from the above post, that I need to put in the following code within the embed code for it to work correctly:

api=1

Can someone help? I'm useless with JS.

Here's the JSFiddle to my slider: http://jsfiddle.net/qcJZY/


回答1:


I basically took the original initialising script from the footer of my .html page, stuck it at the bottom of the main coda-slider.js file and put the following code beaneath it, seems to work:

$(window).bind("load", function() {
 $('#coda-slider-5').codaSlider({
   dynamicArrows: false,
   dynamicTabs: false
 });
});

var pauseVideos = function() {
 $("iframe").each(function() {
  this.contentWindow.postMessage('{ "method": "pause" }', "http://player.vimeo.com");
 });
};

$(function() {
$(".xtrig").bind("click", pauseVideos);    
});


来源:https://stackoverflow.com/questions/9429810/where-does-this-pause-vimeo-embed-code-go-in-my-slider-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!