Plugin: https://github.com/tanepiper/vimeo-froogaloop2/tree/master/javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
var players = []; $(document).ready(function(){ $('.flexslider .slides > li').each(function(index){ if($(this).find('iframe').length > 0){ var iframe = $(this).find('iframe')[0]; players[index] = $f(iframe); }else{ players[index] = null; } }); players[0].addEvent('ready', function() { players[0].api('play'); players[0].api('setVolume', 0); }); $('.flexslider.slider-panel-wrapper').flexslider({ controlNav: false, directionNav: false, slideshow: false, animationSpeed: 800, animationLoop: true, multipleKeyboard: true, pauseOnHover: true, slideshowSpeed: 5000, before: function(slider){ change_before(slider); } }); }); function change_before(slider){ var curr_index = slider.currentSlide; var total = slider.count; var direction = slider.direction; //console.log(slider); //return; if(players[curr_index] != null){ players[curr_index].api('pause'); } if(direction == 'next'){ var next_index = curr_index + 1; if(next_index >= total){ next_index = 0; } }else{ var next_index = curr_index - 1; if(next_index < 0){ next_index = total-1; } } if(players[next_index] != null){ players[next_index].api('play'); players[next_index].api('setVolume', 0); } } |