Vimeo JavaScript Player API

Vimeo JavaScript Player API

Vimeo JavaScript Player API

Several users of my Vimeo Channel Gallery plugin mention that this is not working correctly. In the documentation about Player embedding on Vimeo, regarding the autoplay parameter I use for playing the video, you can read: ‘Play the video automatically on load. Defaults to 0. Note that this will not work on some devices’. Apparently, it is said it cannot work on certain devices, but, what it is sure, given the tests performed, it is that it does not work on certain browsers either. I think it is quite poor that, such an important site as Vimeo, does not specify which devices are referred to.

And that is why I am going to try the Vimeo Player JavaScript. When I started with the plugin I had discarded using the API because it did not provide any method to play a particular video. The only thing offered is the ‘play’ method to reproduce the current video, so the only option left to use it is to modify the player iframe, which must have the following format:

To use the API you have to activate it adding api=1 to the iframe URL and if we are going to have several players in the same web page, we must add to this URL a player_id with the same value of the iframe id.

To allow the connection with the iframe in a secure way, the Vimeo API uses the JavaScript postMessage method, with which we will be able to know the status of the player, which could be one of the following: ready, playProgress, pause, finish. To start the reproduction of the player we will have to wait for the ‘ready’ state, as if we do it before that, the reproduction will fail.

I have created a simple prototype to show the load of different videos on the same player, in order to check the player API use. Also, player status and API methods are shown.

Tags:
©2024 PoseLab SL. All rights reserved.