Skip to content

What is Jetstream player API?

Short description

Jetstream player API is a library that allows you to control an embedded video player from outside an iframe and subscribe to that player's events. Videos are embedded in a website through an iframe tag. As a user, you can play and pause the video by clicking a button within the iframe itself. But how about playing or pausing the video programmatically and receiving events directly from the player?

Since our embedded video player is a separate service that uses video.js under the hood, we cannot do this directly. Modern browsers don't allow this due to CORS policy and MessageEvent API restrictions. Therefore, this library uses postMessage() to send commands directly to the player, where they are processed. On its side, the embedded player sends events that can be captured where it is used.

Thus, we can interact with the player and subscribe to events for the required video or playlist.