This article describes the steps required for building a New Analytics Plugin for the Kaltura Video Player on Android devices.
Create a New Class for the Plugin
First, you’ll need to create a new class for the plugin. The class must extend the PKPlugin to integrate with the Kaltura Video Player.
To configure the plugin protected functions, follow these steps:
1 . Add a factory function - this enables the Kaltura Video Player to create a new instance of the Analytics Plugin and register the new plugin.
2 . When the application sets the Analytics Plugin configuration, the Kaltura Video Player calls the plugin onLoad method. This function contains all of the required configurations for the new plugin, a reference to the active Kaltura Video Player, and a reference to the MessageBus, which includes all events.
3 . Add a listener to the relevant events by calling the following function - all of the relevant events will follow the listener:
4 . Add a send analytics event method and call it from the event listener.
5 . If you want to report events to the application, you can use LogEvent in the following way:
6 . The methods onDestroy, onUpdateConfig, onUpdateMedia, onApplicationPaused, and onApplicationResumed help you manage the life cycle of your Analytics Plugin, including initiating end events, handling background tasks, and keeping the plugin flow in accordance with the Video Player life cycle.
Enable the Analytics Plugin for the Kaltura Video Player on Android Devices
Next, you’ll need to enable the Analytics Plugin by registering it inside the application as follows:
Configure the Plugin Configuration Object for the Analytics Plugin
To configure the Analytics Plugin, add the following configuration to your pluginConfig file as follows:
Set the Plugin Configuration to the Analytics Plugin
For the Analytics Plugin to start loading, you’ll need to set the plugin configugration you created as follows:
MessageBus Supported Events
The MessageBus supports the following events:
Adding New Events Using the MessageBus
If you have new events you need to report, you can add new events by implementing the following steps:
1 . Add a new class for your event.
2 . Implement the PKEvent in this class according the following implementation example:
3 . Use the Messagebus to post your new event:
Setting the Plugin Configuration to the Youbora Plugin
For the Youbora Plugin to start loading, you’ll need to set the plugin configuration you created as follows:
Setting the Plugin Configuration to the IMA Plugin
For the IMA Plugin to start loading, you’ll need to set the plugin configuration you created as follows: