player.js icon indicating copy to clipboard operation
player.js copied to clipboard

Ended event is not fired for our video

Open slavafomin opened this issue 10 years ago • 43 comments

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!

slavafomin avatar Jul 30 '16 12:07 slavafomin

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');
});

landitus avatar Aug 01 '16 03:08 landitus

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.

landitus avatar Aug 01 '16 03:08 landitus

I have no api=1 in the URL of the video, however, the event is still not fired.

slavafomin avatar Aug 01 '16 12:08 slavafomin

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.

landitus avatar Aug 01 '16 14:08 landitus

Can you please link to any videos that aren't working?

bdougherty avatar Aug 01 '16 15:08 bdougherty

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.

landitus avatar Aug 01 '16 18:08 landitus

@bdougherty Please, take a look at my first message. It has the link to the problematic video.

slavafomin avatar Aug 01 '16 21:08 slavafomin

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.

bdougherty avatar Aug 02 '16 21:08 bdougherty

Will wait for it then, thanks. The workaround is working pretty good, so no worries.

slavafomin avatar Aug 03 '16 00:08 slavafomin

Is there a workaround?

This doesn't work either...

player.on('timeupdate', function(data){ console.log('update'); });

mikegarlick avatar Aug 05 '16 15:08 mikegarlick

@mikegarlick make sure you remove the ?api=1 query param from your embed code.

bdougherty avatar Aug 05 '16 23:08 bdougherty

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 avatar Aug 07 '16 09:08 mikegarlick

@mikegarlick please open a new issue and provide a CodePen or JSFiddle that reproduces the issue.

bdougherty avatar Aug 08 '16 16:08 bdougherty

@mikegarlick strange, timeupdate is working fine for me.

slavafomin avatar Aug 08 '16 16:08 slavafomin

@slavafomin can you show me how you have it working? in further detail.

mikegarlick avatar Aug 11 '16 11:08 mikegarlick

@mikegarlick this is my solution:

var finish = _.once(yourOnFinishFunction);

player.on('timeupdate', function(data) {
  if (data.percent === 1) {
    finish();
  }
});

amowu avatar Aug 11 '16 14:08 amowu

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.

slavafomin avatar Aug 11 '16 18:08 slavafomin

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 avatar Sep 13 '16 02:09 LetterAfterZ

@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.

bdougherty avatar Sep 15 '16 18:09 bdougherty

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.

LetterAfterZ avatar Sep 28 '16 04:09 LetterAfterZ