What is Jetstream player API?
Short description
Jetstream player API is a library that allows you to control an embedded video player from the outside of iframe
and subscribe to events of that player. As you know, videos are embedded in a website through an iframe
tag. As a user, you can play and stop the video by clicking a button within the iframe itself. But how about playing/stopping the video programmatically and receiving events directly from the player?
Since our embed video player is a separate service that uses the video.js
under the hood, we cannot do this directly. Modern browsers don't allow this to be done, including due to CORS
policy and MessageEvent API
restrictions. Therefore, in this library, we use postMessage()
methods that send directly to the player and where these methods are processed. On its side, embed player has its own methods that it also sends and that can be caught where it is used.
Thus, we can interact with player and subscribe to the events of the required video or playlist.