Where does this pause vimeo embed code go in my sl

2019-08-30 05:14发布

问题:

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);    
});