Vimeo播放器按钮不会显示

时间:2016-12-17 14:03:33

标签: javascript jquery vimeo-player

我在<body>中有以下脚本:

<script>
(function($) {
        var buttonShowed = false;
        var vPlayer = new Vimeo.Player($('#video0 iframe'));
        vPlayer.on('timeupdate', function(time) {
            if ((time.seconds >=580) && (!buttonShowed) ) {
                buttonShowed = true;
              $('#delayed-button') .css('visibility','visible');
            }
        });

})(jQuery);
</script>

<head>

<script src="https://player.vimeo.com/api/player.js"></script>

Vimeo视频获得了ID video0,按钮获得了ID delayed-button

在我的手机上按钮显示580秒,但在我的电脑上使用不同的浏览器(Chrome,Opera,Safari),按钮不会显示。

我真的不知道为什么,你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

尝试使用div元素而不是iframe,它应该可以使用。似乎timeupdate无法使用iframe

我让你成了一个工作小提琴here。完整代码:

var buttonShowed = false;
 var vPlayer = new Vimeo.Player($('#video0 #player'));
 vPlayer.on('timeupdate', function(time) {
   console.log(time.seconds);
   if ((time.seconds >= 570) && (!buttonShowed)) {
     buttonShowed = true;
     $('#delayed-button').css('visibility', 'visible');
   }
 });
#delayed-button{
  visibility: hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://player.vimeo.com/api/player.js'></script>
<div id='video0'>
  <div data-vimeo-id="76979871" data-vimeo-autoplay="true" id="player"></div>
</div>
<div id='delayed-button'>
  button
</div>