Adding events in Kaltura

Posted By : Pulkit Chadha | 19-Sep-2016

In this blog I am going to explain how you can add events like video start, video complete ,ad cue point reached, ad start , ad complete etc.

Step 1: First setup kaltura in your application.

             <script src="http://cdnapi.kaltura.com/p/{pId}/sp/{partnerId}00/embedIframeJs/uiconf_id/{uiconfId}/partner_id/{partnerId}"></script>
     

Step 2: write the code given below

             
    kWidget.addReadyCallback(function (playerId) {

        var kdp = document.getElementById(playerId);
        
        //kBind method is used to add listener to the player to listen to specific events happened in the player, such as the video is playing or is paused. The opposite of it is kUnbind method.


        // This event triggeres once per video when first played.
        kdp.kBind("firstPlay", function () {
            console.log("video start");
        });

        // This event triggeres when video has reached the end of content playback.
        kdp.kBind("playerPlayEnd", function () {
            console.log("video complete");
        });

        //This event triggeres when the player's time progress reaches an ad cue point
        kdp.kBind("adOpportunity", function (qPoint) {
            console.log("adcuePointReached ", qPoint);
        });

        //This event triggeres when the ad starts to play.
        kdp.kBind("onAdPlay", function () {
            console.log("Ad start");
            var url = kdp.evaluate('{sequenceProxy.activePluginMetadata}').url;
        });

        //This event triggeres when video has reached the end of content playback.
        kdp.kBind("onAdComplete", function () {
            console.log("Ad complete");
            var url = kdp.evaluate('{sequenceProxy.activePluginMetadata}').url;

        });
    });
      

About Author

Author Image
Pulkit Chadha

Pulkit is an expert web app developer and has good knowledge of JQuery, MongoDb, NodeJs, AngularJS, kaltura, Akamai. etc.

Request for Proposal

Name is required

Comment is required

Sending message..