This document explains how Zype’s Player Event Framework enables web applications to listen for and respond to key player events generated by the Zype Player powered by Bitmovin.
Topics covered include:
-
-
What is a player event
-
Technologies used to dispatch player events
-
Event types supported
-
Player event structure and examples
-
Adding custom metadata to dispatched events
-
Dispatching logic and window targeting
-
How to listen for player events
-
What is a Player Event?
A player event is a structured message containing information about the current state or action of the video player.
For example:
-
When a viewer presses play, a
zype:playevent is dispatched. -
When playback ends, a
zype:completeevent is dispatched.
These events can be listened for by applications to trigger analytics, UI changes, or any custom business logic.
Behind the Scenes: Technologies Used to Dispatch Player Events
CreateEvent (Legacy JavaScript Events)
In early implementations, Zype used the standard JavaScript event model (createEvent) to dispatch messages directly to the DOM. This approach worked only for JavaScript embeds and lacked cross-origin compatibility.
PostMessage (Current Implementation)
The Zype Player now uses the PostMessage API to broadcast events in a secure, cross-origin manner that works consistently across JavaScript and iFrame embeds.
Reference: MDN PostMessage Documentation
PostMessage enables the player to send events safely from the embedded player context to the parent window or same-page environment, depending on the embed type.
Browser Support: Fully supported across all modern browsers.
Browser Support for PostMessage
PostMessage has full support for modern browsers (graphic provided by MDN):
Supported Event Types
The following event types are currently supported by the Zype Player Event Framework:
| Event Type | Description |
|---|---|
zype:ready |
Dispatched when the player is initialized and ready for playback. |
zype:play |
Dispatched when playback begins. |
zype:pause |
Dispatched when playback pauses. |
zype:error |
Dispatched when an error occurs during playback. |
zype:complete |
Dispatched when playback reaches the end of the content. |
zype:adstart |
Dispatched when an ad starts playing. |
zype:adcomplete |
Dispatched when an ad finishes playing. |
zype:aderror |
Dispatched when an ad fails to play or encounters an error. |
Note: All Zype events are prefixed with
zype:to differentiate them from other messages that may appear on your page (e.g., YouTube or Vimeo events).
Event Structure
Event data is sent as a string for compatibility across browsers. Use JSON.parse() to convert the message back to a JSON object.
Example:
Fields:
-
event — The name of the event (
zype:ready,zype:play, etc.) -
id — The ID of the video generating the event
-
info — Optional object for custom metadata (e.g., playlist, app, or page context)
Adding Custom Metadata to Dispatched Events
You can attach custom metadata to player events using the info query parameter in the embed URL.
Example:
Output:
This allows you to tie events to your own contextual data such as the page name, user session, or campaign ID.
Event Dispatching
Events are dispatched directly from the Zype Player powered by Bitmovin whenever a corresponding player event is triggered.
Internally, Zype maps Bitmovin player state changes to Zype event messages, for example:
EventManager and Window Targeting
The Zype Player Event Framework manages event delivery using an internal EventManager, which determines how and where to send events depending on the embed type.
-
iFrame Embeds:
Events are sent from the iframe to the parent window usingwindow.parent.postMessage(). -
JavaScript Embeds:
Events are sent to the current window context usingwindow.postMessage().
How to Listen for Player Events
To listen for player events on your page, use the standard window.addEventListener method and filter for Zype event messages.
Example:
Event Origin
-
For iFrame Embeds: The origin will be
https://player.zype.com -
For JavaScript Embeds: The origin will match your current page domain
Always validate the message origin to ensure it’s coming from a trusted Zype player instance.
Summary
The Player Event Framework provides a consistent and secure way to interact with the Zype Player powered by Bitmovin, enabling custom analytics, automation, and UI behavior across embeds.
For additional details, refer to:
Was this article helpful?
Articles in this section
- Video Segments
- Dynamic Player Technology - Custom API Integration
- Limit Distribution by Geography and Video Source to Manage Licensing Agreements
- SMTP Settings
- Adaptive Bitrate (ABR) Support in the Zype Web Player
- Managing Player Rules
- Setting Up Player Rules
- Enabling Social Sharing Controls for Zype players
- Player Messaging
- Player Branding