Event

This section describes the various events that occur in the OvenPlayer instance.

Prerequisites

Register an event

// Attach event listener.
player.on('EventName', function(data){
    console.log(data);
});

// Attach event listener works only once.
player.once('EventName', function(data){
    console.log(data);
});

Cancel a registered event

// Remove all listeners for event type
player.off('EventName');

// Remove specific listener for event type
player.off('EventName', listener)

on('ready')

Player initialization complete. And you can use API methods.

on('metaChanged')

Returns Object:

It occurs when new metadata is received.

on('stateChanged')

Returns Object:

It occurs when the state of a player changes.

idle, complete, paused, playing, error, loading, stalled, 
adLoaded, adPlaying, adPaused, adComplete

on('resized')

Returns String: Fired when the player's size has been changed. ("large", "medium", "small", "xsmall")

large(>992), medium(<992), small(<768), xsmall(<576)

on('playbackRateChanged')

Returns Object:

Fired when the playback rate has been changed.

on('seek')

Returns Object:

Fired after a seek has been requested either by scrubbing the control bar or through the API.

on('seeked')

Triggered when video position changes after seeking, as opposed to on('seek') which triggers as a seek occurs.

on('time')

Returns Object:

While the player is playing, this event is fired as the playback position gets updated. This may occur as frequently as 10 times per second.

on('bufferChanged')

Returns Object:

Fired when the currently playing item loads additional data into its buffer.

on('mute')

Returns Number**:** New volume percentage (0-100)

Triggered when the player has gone in or out of a mute state.

on('volumeChanged')

Returns Number**:** New volume percentage (0-100)

Triggered when the player's volume is changed.

on('playlistChanged')

Returns Number**:** index of the new playlist index

Fired when the active playlist is changed. It happens in response to, e.g., a user clicking an option in the playlist menu or a script calling setCurrentPlaylist or prev playlist has been completed.

on('sourceChanged')

Returns Number**:** index of the new quality level in the getSources() array

Fired when the active source(protocol) is changed. It happens in response to, e.g., a user clicking an option in the source menu or a script calling setCurrentSource.

on('qualityLevelChanged')

Returns Object:

Fired when the active quality level is changed. It happens in response to, e.g., a user clicking an option in the quality menu or a script calling setCurrentQuality.

on('cueChanged')

Returns Object:

Fired when VTTCue is changed.

on('timeDisplayModeChanged')

Returns Boolean : changed displaying mode

Fired when timecode mode is changed.

on('adChanged')

Returns Object:

Fired when Ad is changed.

on('adTime')

Returns Object:

Fired when Ad is playing.

on('adComplete')

Fired when Ad is complete.

on('fullscreenChanged')

Returns Boolean : True if the screen is full, false otherwise.

Fired when screen mode is changed.

on('clicked')

Returns Object:

Triggered when the player is clicked. If ad clicked, this returns {type : "adclick"}.

on('allPlaylistEnded')

Fired when the all playlist is complete.

on('hlsPrepared')

Returns Object:

Triggered when HLS object is initialized and ready to use.

on('hlsDestroyed')

Triggered after HLS object is destroyed.

on('dashPrepared')

Returns Object:

Triggered when DASH object is initialized and ready to use.

on('dashDestroyed')

Triggered after DASH object is destroyed

on('destroy')

Player is destroyed.

Last updated