$(document).ready(function ()
{
var player_1_listener = $('#myVid_1')[0];
$f(player_1_listener).addEvent('ready', ready);
var player_2_listener = $('#myVid_2')[0];
$f(player_2_listener).addEvent('ready', ready);
function addEvent(element, eventName, callback)
{
if (element.addEventListener)
{
element.addEventListener(eventName, callback, false);
}
else
{
element.attachEvent(eventName, callback, false);
}
}
function ready(player_id)
{
//var froogaloop = $f(player_id);
if (player_id === myVid_1)
{
var froogaloop = $f(player_id);
function onFinish()
{
froogaloop.addEvent('finish', function(data)
{
/*var players_unloading;
players_unloading=$('#myVid_1');
$f(players_unloading[0]).api('unload');*/
toggleOverlay_1();
$f(froogaloop[0]).api('unload');
});
}
//onFinish();
}
else if (player_id === myVid_2)
{
var froogaloop = $f(player_id);
function onFinish()
{
froogaloop.addEvent('finish', function(data)
{
/*var players_unloading;
players_unloading=$('#myVid_1');
$f(players_unloading[0]).api('unload');*/
toggleOverlay_2();
$f(froogaloop[0]).api('unload');
});
}
//onFinish();
}
}
onFinish();
});
I have 2 buttons which on clicking open an iframe and play videos. I am trying to get the player within the iframe to call it's api pause method to pause the video. I can do this well if I use only one iframe video, but I am unable to do when there are multiple iframe videos.