Player Events

Event listeners can be set on the player events (after the player has been created and initialized).

How To

Available player listening options:

  1. Single Event - Listen for single event
  2. Collection - Listen for all events
  3. Map - Listen for events specified on a map

Single Event

Call the listen method for a specific event, in this case playerReady (see example):

player.events().playerReady.listen(function(result)
{
    // Triggered once the player is ready
});

Collection

Call the listen method on the entire collection of events (see example):

var PlayerEventType = TOP.events.PlayerEventType;

player.events().listen(function(type, result)
{
    switch (type)
    {
        case PlayerEventType.Player_Ready:
            // Triggered once the player is ready
            break;
    }
});

Also see PlayerEventType enum to check the type parameter for the type of event.

Map

Call the listen method providing a map of events (see PlayerApiEvents for key values) (see example)::

player.events().listen({
    playerInitialized: function(result) {
        // Triggered once the player is initialized
    },
    playerReady: function(result) {
        // Triggered once the player is ready
    },
    ...
});