Event listeners

Working with player listeners

Bind event

Add your custom listener and bind it to the start event of the player.

Example:

$bp().on('start', listener)
Attribute nameDescription
ready stringName of the event
listener functionFunction which will be called when ready fires

Unbind event

Remove your custom listener.

Example:

$bp().off('start');

Bind event listener to execute only once

If you want to execute your custom callback only on first occurence of the event.
Example:

$bp().once('start', function(){ console.log("Execute only once."});

Player ready listener example

Check if player is ready for API usage.

All custom code that you plan to integrate with our player should be done after this callback is fired.
If this callback if fired from the player, it means that all player components are loaded on the page and custom code can be executed.

Example

function ready() {
    // Insert code to execute when player is ready for API usage
}
$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"480",
	"video":"VIDEO_ID"
	}, ready);
$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"480",
	"video":"VIDEO_ID"
	});

$bp().on("ready", function(){ console.log("I am ready!")});