Skip to main content

Events

The WebPlayer component provides various events that you can listen to or handle via callback props. These events allow you to respond to different states and actions within the WebPlayer.

Event Handling Options

There are two main ways to handle WebPlayer events:

  1. Using callback props on the WebPlayer component when using frameworks
  2. Adding event listeners directly (vanilla JavaScript)

The table below lists all available events, their types, and descriptions. An example of how to use these events is provided below each table.

EventTypeDescription
onCompositionLoading(url: string) => voidTriggered when the composition is loading.
onCompositionLoaded(composition: Composition) => voidTriggered when the composition has successfully loaded.
onCompositionLoadError(error: unknown) => voidTriggered when there is an error loading the composition.
onItemChange(props: { index: number; item: Item }) => voidTriggered when there is on a carrousel focus changed.
onExtendModeOn() => voidTriggered when the extend mode is turned on.
onExtendModeOff() => voidTriggered when the extend mode is turned off.
onHotspotsOn() => voidTriggered when hotspots are turned on.
onHotspotsOff() => voidTriggered when hotspots are turned off.
onGalleryOpen() => voidTriggered when the gallery is opened.
onGalleryClose() => voidTriggered when the gallery is closed.

Example

<WebPlayer
...
onCompositionLoaded={composition => console.log("Composition loaded !", composition)}
>

info
  • The default prefix for all WebPlayer events is "cc-webplayer:". This prefix helps to avoid potential conflicts with other events in your application. You can access it through the constant DEFAULT_EVENT_PREFIX
  • You can customize the event prefix by setting the eventPrefix property on the WebPlayer component.