跳到主要内容

Callback Integration

Playback Logs

To retrieve logs of the player's video playback behavior, listen for the infoDelivery event, which is sent every 0.5 seconds:

<script>
  window.addEventListener('message', messageEvent => {
    const parseData = JSON.parse(messageEvent.data)
    if (parseData.event !== 'infoDelivery') {
      return
    }
    console.log(parseData)
  })
</script>

Playback Event

You will retrieve playback events after triggered:

{
event: 'infoDelivery',
info: {
currentTimeLastUpdated:,// Unix time when the event sent
playlogData: {
playback_module_version: "",
system_time:,// Unix time when the event sent
},
playlogEventName: "",
}
}

Playback Error Event

To handle playback errors, you can identify them by tracing the event playlogEventName with the specified value playback_error_occurred. Here is an example of the event structure:

{
event: 'infoDelivery',
info: {
currentTimeLastUpdated:,// Unix time when the event sent
playlogData: {
playback_module_version: "",
system_time: 0,// Unix time when the event sent
error_code: 0, // The specified error code
error_reason: "" // The corresponding error reason
},
playlogEventName: "playback_error_occurred",
}
}

When a playback error occurs, the event will contain the following details:

Playback Error Codes and Reasons

Error CodeError ReasonDescription
5ERROR_REASON_RESOURCE_NOT_FOUNDNo content available.
7ERROR_REASON_DOMAIN_INVALIDNot in the authorized domain to watch.
7ERROR_REASON_OVER_DEVICE_LIMITReached the maximum limit for simultaneous playback on devices.
7ERROR_REASON_PLAYBACK_SESSION_EXPIREDThe playback session is expired due to an unstable network or the iframe losing focus.
16ERROR_REASON_TOKEN_INVALIDThe token used for playback is not valid (i.e. unauthenticated).
16ERROR_REASON_TOKEN_EXPIREDThe token used for playback is expired.

Playback Progress

You will retrieve the progress of the VOD playback by your users. The following example shows playback progress for a user who has watched up to the 171-second position of a VOD at a playback speed of 1.25x:

{
event: 'infoDelivery',
info: {
currentTime: 171,
currentTimeLastUpdated:, // Unix time when the event sent
playbackRate: 1.25,
}
}

Back Button Clicking Logs

When customizing the layout of the iframe player as a Standalone design, a Back button will be provided in the player's UI. This Back button empowers you to manage the behavior that is triggered upon clicking it. For instance, you can navigate back, redirect to a specific page of your choice, or implement any subsequent behaviors on your end when the user clicks the button.

To manage the behavior associated with the Back button, listen for the actionDelivery message to retrieve the log, which will inform you of the user's clicking event on it:

window.addEventListener('message', messageEvent => {
const messageData = JSON.parse(messageEvent.data)
if (messageData.event === 'actionDelivery' && messageData.name === 'back') {
// actions for back button
}

console.log(messageData)
/*
{
event: 'actionDelivery',
name: 'back'
}
*/
})