简体   繁体   English

Vimeo JS API - Froogaloop - 立即/太早完成事件调用?

[英]Vimeo JS API - Froogaloop - Finish event calls immediately/too early?

According to the vimeo js-api doc , the event finish - Fires when the video playback reaches the end. 根据vimeo js-api doc ,事件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? 出于某种原因,我不能让这个工作, finish事件总是立即调用,我做错了什么?

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. 我已经按照Drew Baker的例子进行了操作,但是无法正常调用finish事件。

I have made a very straightforward jsbin here to demonstrate the issue. 在这里做了一个非常简单的jsbin来证明这个问题。

This behaviour seems to be occurring on Safari, Chrome and Firefox (on mac). 这种行为似乎发生在Safari,Chrome和Firefox(在Mac上)上。

-- -

JS Code from JSBIN: 来自JSBIN的JS代码:

$(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. 您正在执行函数,而不是将函数引用传递给addEvent方法。

Froogaloop(playerID).addEvent('play', play);
Froogaloop(playerID).addEvent('seek', seek);
Froogaloop(playerID).addEvent('finish', onFinish);

Note that Froogaloop passes the playerID as an argument to the play callback function, I'm not certain that it passes the playerID as an argument to the finish callback function (although I'm guessing it probably does). 请注意, FroogaloopplayerID作为参数传递给play回调函数,我不确定它是否将playerID作为参数传递给finish回调函数(尽管我猜它可能会这样做)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM