Vimeo Player button won't show up

232 views Asked by At

I have following script in the <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>

In the <head>:

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

The Vimeo Video got the ID video0 and the button got the ID delayed-button.

On my phone the button shows on 580 seconds but with different browsers (Chrome, Opera, Safari) on my PC the button does not show up.

I really don't why, can you help me?

1

There are 1 answers

8
Ionut Necula On BEST ANSWER

Try using a div element instead of an iframe and it should work. It seems that timeupdate is not working with iframe.

I've made you a working fiddle here. The full code:

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>