Ended event is not fired for our video
Hello there!
Thank you for this new API, it looks much better than Froogaloop.
However, we have some issues with ended / finished event. It's not called for our video. But, if we use some other public video from Vimeo it works OK. Maybe there is some issue with privacy or embed settings? It was working some time ago and was broken recently. We are experiencing this problem for both API versions of Vimeo.
For now I have to use:
timeupdate: function (event) {
if (event.percent >= 0.95) {
// Video finished...
}
}
Also, the last called timeupdate event has percentage around 0.99, it's never called with 1.0, maybe it's somehow related to ended problem.
Thank you!
I have the same issue, the event 'ended' is not fired when the video ends.
var player = new Vimeo.Player($('iframe'));
// Auto-Play video
player.play();
player.on('play', function(data){
console.log('play');
});
player.on('ended', function(data){
console.log('Ended');
});
Ok, I should have looked first, but found this issue that solves this problem by removing the api=1 from the API call. Maybe this is something I had from the previous Froogaloop implementation.
I have no api=1 in the URL of the video, however, the event is still not fired.
It's odd, some videos fire the event and some do not. The removal of api=1 helped, but still It's not working completely. I'm loading the videos via an Ajax call, btw.
Can you please link to any videos that aren't working?
I've been trying to reproduce the bug, but It's pretty random and it's not bound to any particular video. When I find a way to reproduce it I'll paste it here.
@bdougherty Please, take a look at my first message. It has the link to the problematic video.
Unfortunately there's not a whole lot we can do to fix this at the moment. We have some upcoming changes coming to how we deliver files and I've confirmed that those changes fix the bug.
Will wait for it then, thanks. The workaround is working pretty good, so no worries.
Is there a workaround?
This doesn't work either...
player.on('timeupdate', function(data){ console.log('update'); });
@mikegarlick make sure you remove the ?api=1 query param from your embed code.
I haven't got the the ?api=1 in the query param. The only callback I that works for me is the:
player.on('play', function(){});
@mikegarlick please open a new issue and provide a CodePen or JSFiddle that reproduces the issue.
@mikegarlick strange, timeupdate is working fine for me.
@slavafomin can you show me how you have it working? in further detail.
@mikegarlick this is my solution:
var finish = _.once(yourOnFinishFunction);
player.on('timeupdate', function(data) {
if (data.percent === 1) {
finish();
}
});
Be advised, that in my case it never reaches 1.0, so you have to check for something like 0.99, e.g.: event.percent >= 0.99.
Having this exact same issue on a build right now.
I switched from Froogaloop2, everything else is working except ended.
I've also noticed that despite not adding api=1 in my embed code, it's automatically added to my video - is that an embed setting on my video doing that somehow?
UPDATE: Strangely I can use; "player.on('finish', function(){ " and that works...
@LetterAfterZ I'm not sure how api=1 is being added if it's not in your embed code. As long as it's there, you'll have to use the older method names (including finish). We'd like to make that behavior work a little better, but I'm not sure when we will be able to get to it.
Thanks @bdougherty. Turns out one of my 3rd party scripts (fullpage.js - http://www.alvarotrigo.com/fullPage/) thought it'd be useful to add api=1 to every Vimeo video.
I made a quick edit to solve this problem and now we're all good.