Capturing kaltura player events within Player UI

Hi Experts,

We want to send player events like doPlay, doPause etc to external analytics system upon player interaction. For this purpose, we thought of using “IframeCustomPluginJs1” and subscribe to events from an external JS file that contains the following code.

kWidget.addReadyCallback(function(playerId) {
var kdp = document.getElementById(playerId);

kdp.kBind('doPause', function() {
    alert(`Event Triggered for 'doPause'`);
    kdp.kUnbind('doPause');
    kdp.sendNotification("mediaDownloadCustom", { entryID: kdp.evaluate('{mediaProxy.entry.id}') });
});

kdp.kBind('doPlay', function() {
    alert(`Event Triggered for 'doPlay'`);
    kdp.kUnbind('doPlay');
});

kdp.kBind('doStop', function() {
    alert(`Event Triggered for 'doStop'`);
    kdp.kUnbind('doStop');
});

kdp.kBind('mediaDownloadCustom', function(data) {
    alert(`Custom Event Triggered for 'mediaDownloadCustom' with ID: ${data.entryID}`);
    kdp.kUnbind('mediaDownloadCustom');
});

$('.controlsContainer .download').click(() => {
    debugger;
    kdp.sendNotification("mediaDownloadCustom", { entryID: kdp.evaluate('{mediaProxy.entry.id}') });
})

});

This will ensure that our events are getting captured irrespective of where the player is embedded as an iframe.

BUT we are unable to see these events being fired from player UI interaction. Also, I don’t see any alert box or debugger or error in console UI.

So question is, does kaltura support sending/subscribing to events from IframeCustomPluginJs1 or not? if not then how can we make sure that events are successfully captured everywhere without writing the repitative code?

Thank You
Saurabh Kabra

Hi @saurabhkabrasap,

Take a look here: https://github.com/kaltura/mwEmbed/blob/master/modules/KalturaSupport/resources/mw.KAnalytics.js

Thanks,