Reputation: 11
I'm having problems firing and listening to events with the froogaloop api. My code is :
$f('player').addEvent('ready', video.load);
$f('player').addEvent('play', video.show);
$f('player').addEvent('finish', video.unload);
And my function:
load: function() { $f('player').api('play'); }
And the video.show() function never starts..! Can you help me?
Upvotes: 1
Views: 2260
Reputation: 7119
You need to wrap your player events inside the ready
event.
So in your case, you can do it like this:
var player = $f('player');
// Listen for the 'ready' event
player.addEvent('ready', function () {
// Now you can start listening to all other events
player.addEvent('play', video.show);
player.addEvent('finish', video.unload);
});
See the Events section on Vimeo's API documentation page. It says:
Do not try to add listeners or call functions before receiving this (
ready
) event.
Upvotes: 1