JavaScript API: addListener

Method to add functions to listen for player events.

Function:

/**
 *Add function to listen for player evebts
 *
 *@param eventType One of the events constants found on the JarisFLVPlayer.event object.
 *@param string with the name of the function that is going to listen
 */
function addListener(eventType, listenerFunction);

The listener function needs 1 parameter that is passed to it with the following values:

data = {
    duration,      //Total time in seconds
    fullscreen,    //Fullscreen status
    mute,           //Mute status
    volume,       //Current volume value
    position,      //Current position in seconds
    type,           //Event type name
    loaded,       //Amount of bytes loaded
    total            //The total amount of bytes
};

Event types found on the JavaScript.event object:

JarisFLVPlayer.event = {
    MOUSE_HIDE: "onMouseHide", 
    MOUSE_SHOW: "onMouseShow",
    MEDIA_INITIALIZED: "onDataInitialized",
    BUFFERING: "onBuffering",
    NOT_BUFFERING: "onNotBuffering",
    RESIZE: "onResize",
    PLAY_PAUSE: "onPlayPause",
    PLAYBACK_FINISHED: "onPlaybackFinished",
    CONNECTION_FAILED: "onConnectionFailed",
    ASPECT_RATIO: "onAspectRatio",
    VOLUME_UP: "onVolumeUp",
    VOLUME_DOWN: "onVolumeDown",
    VOLUME_CHANGE: "onVolumeChange",
    MUTE: "onMute",
    TIME: "onTimeUpdate",
    PROGRESS: "onProgress",
    SEEK: "onSeek",
    ON_ALL: "on*"
};

Example:

//Triggers for every event. The data parameter holds some useful data passed by the player.
function onAll(data){
    //Displays the type of event that was triggered
    alert(data.type);
}

//Initialize the interface
player = new JarisFLVPlayer("Id_Of_Player_Object");

//Adds a catch all event listener
player.addListener(JarisFLVPlayer.event.ON_ALL, "onAll");

//Start playback
player.play();
Fork me on GitHub