I have an error when I try to use Vimeo SDK

66 Views Asked by At

I'm trying to use Vimeo js SDK to check when someone play or stop a video.

I have read the oficial documentation: https://developer.vimeo.com/player/sdk/basics.

The extrange thing is that in Vimeo example the website only have one iframe:

<html>
<head>
  <title>{page_title}</title>
</head>
<body>

  <iframe src="https://player.vimeo.com/video/{video_id}?h={hash_parameter}" width="{video_width}" height="{video_height}" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

  <script src="{url}"></script>
  <script>
    var iframe = document.querySelector('iframe');
    var player = new Vimeo.Player(iframe);

    player.on('play', function() {
      console.log('Played the video');
    });

    player.getVideoTitle().then(function(title) {
      console.log('title:', title);
    });
  </script>

</body>
</html>

When I run the code:

    var iframe = document.querySelector('iframe');
    var player = new Vimeo.Player(iframe);
    

In the console browser i get this error: Uncaught ReferenceError: Vimeo is not defined But If I check the browsern network, I have the js library loaded.

enter image description here

I'm not sure what it's wrong.

0

There are 0 best solutions below