跳到主要内容

Callback Integration

Media Event Handlers

Use this if you want to trigger actions for specific media events.

The addEventListener method adds an event listener to the underlying media element. You can use all HTML video events defined in HTMLMediaElement events.

Example:

const player = createPlayer('player-container', {
license, // license is not required when testing in local development environment
source: [
{
type: 'application/dash+xml',
src: dashUrl,
},
{
type: 'application/x-mpegurl',
src: hlsUrl,
}
],
})

player.addEventListener('pause', () => {
displayBanner()
})

player.addEventListener('play', () => {
hideBanner()
})

Playback Log Events

Use this if you want to integrate with your own analytics/log service.

To receive event logs, integrate the PlaybackEvent callback function in the Player SDK by attaching the onPlayLogFired handler:

const player = createPlayer('player-container', {
license, // license is not required when testing in local development environment
source: [
{
type: 'application/dash+xml',
src: dashUrl,
},
{
type: 'application/x-mpegurl',
src: hlsUrl,
}
],
onPlaylogFired: (event) => {
// Your own log service integration here
console.debug("onPlayLogFired", event)
}
})