According to the vimeo js-api doc, the event finish - Fires when the video playback reaches the end.
For some reason, I can't get this to work, the finish
event always calls immediately, am I doing something wrong?
I am trying to make an embedded video disappear when it is finished playing. I have followed this example by Drew Baker but simply cannot get the finish
event to call properly.
I have made a very straightforward jsbin here to demonstrate the issue.
This behaviour seems to be occurring on Safari, Chrome and Firefox (on mac).
--
JS Code from JSBIN:
$(document).ready(function() {
$('iframe.vimeo').each(function(){
Froogaloop(this).addEvent('ready', ready);
});
function ready(playerID){
Froogaloop(playerID).addEvent('play', play(playerID));
Froogaloop(playerID).addEvent('seek', seek);
Froogaloop(playerID).addEvent('finish', onFinish(playerID));
Froogaloop(playerID).api('play');
}
function play(playerID){
alert(playerID + " is playing!!!");
}
function seek() {
alert('Seeking');
}
function onFinish(playerID) {
alert(playerID + " finished!!!");
$('#'+playerID).remove();
}
});
You are executing functions instead of passing the function reference to the
addEvent
method.Note that
Froogaloop
passes theplayerID
as an argument to theplay
callback function, I'm not certain that it passes theplayerID
as an argument to thefinish
callback function (although I'm guessing it probably does).