Reputation: 179
I'm trying to call a function once the play button on a Vimeo video has been clicked.
For some reason the function is called while the iframe is loading, rather than when play is clicked. Could somebody explain why?
This is my code:
// Enable the API on each Vimeo video
jQuery('iframe.vimeo').each(function(){
Froogaloop(this).addEvent('ready', ready);
});
function ready(playerID){
// Add event listerns
// http://vimeo.com/api/docs/player-js#events
Froogaloop(playerID).addEvent('play', play(playerID));
}
function play(playerID){
alert(playerID + " is playing!!!");
}
Thanks!
Upvotes: 2
Views: 1484
Reputation: 179
Ahhh figured it out!
// Enable the API on each Vimeo video
jQuery('iframe.vimeo').each(function(){
Froogaloop(this).addEvent('ready', ready);
});
function ready(playerID){
// Add event listerns
// http://vimeo.com/api/docs/player-js#events
Froogaloop(playerID).addEvent('play', function(data) {play(playerID);});
}
function play(playerID){
alert(playerID + " is playing!!!");
}
Hopefully someone will find that helpful!
Upvotes: 3