API Control Vimeo videos (play and mute) with Flex slider

Plugin: https://github.com/tanepiper/vimeo-froogaloop2/tree/master/javascript

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