Init Config

Event listener(s) can be set on the init config events (when the player is being created and initialized via createAndInitPlayer).

How To

Types to pass to events:

  1. Map - specify an object defining specific event listeners
  2. Collection - pass a function which listens for all player events

Map

Pass an object to the events config whose property names (see PlayerApiEvents) are the specific events to listen for, (see example):

var player = TOP.createAndInitPlayer({
    events: {
        playerReady : function(result) {
            // Only triggered when player is initialized and ready to play
        },
        ...
    }
});

Collection

Pass a function to the events config. This function will be triggered by all player events (see example):

var player = TOP.createAndInitPlayer({
    events: function(type, result)
    {
        // All player events will fire here
    }
});

Also see PlayerEventType enum to check the type parameter for the type of event (see source code for example).