The player communicates its current state through various events and keeps track of assorted modes and phases.
Events can be listened to using the JavaScript API described below, while modes and phases can be queried at any time via API functions.
1.0 | Events
Events indicate every action the player makes, such as play, pause, or switching to full screen. Events can be used as callbacks (triggered by a command) or to retrieve specific information passed along with the event (such as the current playback time). Subscribe to events with on() and unsubscribe with off(). Event names accept an optional namespace (e.g. 'canplay.myapp') which lets you remove a specific listener without affecting others registered on the same event.
Example: Start all API calls from inside the ready event to ensure the player is fully initialised.
player.on('ready', function(){
player.play();
});1.1 | Media Events
| Event name | Description | Related API function |
|---|---|---|
load | Media data loading started | |
loadeddata | Media data was loaded | |
loadedmetadata | Media metadata was loaded | |
canplay | The player is now ready to play. | play() |
play | The player has executed a play command. | |
pause | The player is now paused. | |
playing | The player is now playing. | |
seeking | The player is now seeking. | |
seeked | The current playback position has changed by the player as a result of a seek action. | |
ended | Playback has stopped because the end of the media resource was reached. | |
started | The player has started for the first time. This event happens at most once during a player session. | |
timeupdate | The time has been updated by the player. Note: The time reported by the player changes between timeupdate events. The rate of this event is throttled due to performance reasons. | getCurrentTime() |
stalled | The player is trying to fetch new media data, but is unable to retrieve it and continue playing. | |
unstalled | The player is able to continue playing. | |
progress | The buffer has been updated by the player. | getBuffered() |
error | The player has encountered an error which prevents it from playing the content further. | |
aderror | The advertisement provider encountered an error which prevents the ad from playing in the player. | |
adnotfound | The advertisement provider did not find an ad to play in the player. |
Example: Play the player when it is ready to play.
player.on('canplay', function(){
player.play();
});Example: Log the current playback position on every timeupdate.
player.on('timeupdate', function(){
console.log('Current time: ' + player.getCurrentTime());
});1.2 | Data Events
| Event name | Description | Related API function |
|---|---|---|
loadedplayoutdata | Playout data is loaded. | getPlayoutData() |
changedplayoutdata | Playout data changed. | getPlayoutData() |
loadedclipdata | Clip data is loaded. | getClipData() |
loadedcliplistdata | Clip list data is loaded. | |
changedcliplistdata | Clip list data has changed. | |
loadedprojectdata | Project data is loaded. | getProjectData() |
loadedinteractivity | Interactive content has been loaded. | |
chapterlistchange | The list of chapters has changed. | getChapterList() |
highlightlistchange | The list of highlights has changed. | |
relatedclipschange | The list of related clips has been loaded or changed. | getRelatedList() |
assetlistchange | The list of assets has changed. | getAssets() |
audiotracklistchange | The list of audio tracks has changed. | getAudioTracks() |
texttracklistchange | The list of text tracks has changed. | |
transcriptlistchange | The list of transcripts has changed. | |
transcriptchange | The active transcript has changed. | |
durationchange | The duration of the clip has changed. | getDuration() |
Example: Read clip metadata once it has loaded.
player.on('loadedclipdata', function(){
var clipData = player.getClipData();
console.log('Clip title: ' + clipData.title);
});1.3 | State Changes
| Event name | Description | Related API function |
|---|---|---|
modechange | The mode has changed. The wrapper class bb-mode-{mode} has also changed. | getMode() |
statechange | The state has changed. The wrapper class bb-state-{state} has also changed. | getState() |
phasechange | The phase has changed. The wrapper class bb-phase-{phase} has also changed. | getPhase() |
flagchange | A flag has changed. | getFlag(flagname) |
1.4 | Ad-related Events
| Event name | Description |
|---|---|
adstarted | An ad has started. |
adquartile1 | An ad has reached its first quartile. |
adquartile2 | An ad has reached its second quartile. |
adquartile3 | An ad has reached its third quartile. |
adfinished | An ad has finished. |
adskippable | An ad has become skippable. |
adclicked | The user has clicked on an ad. |
1.5 | Autoplay Next Events
| Event name | Description |
|---|---|
autoplaynexttimerstarted | The AutoPlayNext timer has started. |
autoplaynexttimercancelled | The AutoPlayNext timer was cancelled. |
autoplaynexttimertick | The AutoPlayNext timer has ticked. |
autoplaynexttimerfinished | The AutoPlayNext timer has finished. |
autoplaynexttimerpaused | The AutoPlayNext timer has paused. |
autoplaynexttimerresumed | The AutoPlayNext timer has resumed. |
1.6 | Soft Embargo Timer Events
| Event name | Description |
|---|---|
softembargotimerstarted | The soft embargo timer has started. |
softembargotimertick | The soft embargo timer has ticked. |
softembargotimerfinished | The soft embargo timer has finished. |
softembargotimercancelled | The soft embargo timer was cancelled. |
1.7 | General Events
| Event name | Description | Related API function |
|---|---|---|
ready | The player API is ready and functions can be called from the API. | |
assetselected | A different asset has been selected by the player. | getCurrentAsset() |
audiotrackchange | A different audio track was selected by the player. | getCurrentAudiotrack() |
volumechange | The volume has changed. | getVolume() |
subtitlechange | The subtitle language has changed. | getCurrentSubtitle() |
subtitlelinechange | The current subtitle line has changed. | getCurrentSubtitleLine() |
resized | The player size has been changed. | |
inview | The player is now inside the user agent’s viewport. | |
outview | The player is now outside the user agent’s viewport. | |
fullscreen | The player is now fullscreen. | |
retractfullscreen | The player is now not fullscreen. | |
floatstart | The player initiated floating behaviour. | |
floatend | The player stopped floating behaviour. | |
autopause | The player was automatically paused (e.g. when scrolled out of view). | |
contentblocked | Content playback was blocked (e.g. due to geo-restriction or age-gating). | |
castsessionchange | The cast session has changed. | |
collapsed | The player UI has collapsed. | |
expanded | The player UI has expanded. | |
fullscreenmismatch | A mismatch was detected between the player’s fullscreen state and the browser’s. | |
fullscreenmismatchresolved | A fullscreen state mismatch has been resolved. |
2.0 | Modes
The player runs in different modes dependent on the current media type. For example, the player has a different mode for live content than it has for commercial content.
The current mode can be retrieved by calling getMode(). The event modechange is fired when the mode changes.
| Mode name | Class | Description |
|---|---|---|
static | bb-mode-static | The player has static content loaded, such as an image, a document, or interactive content. |
commercial | bb-mode-commercial | The player is playing a VMS creative, VAST source or any other commercial. |
audio | bb-mode-audio | The player is playing audio only content. Note: The player can still display a thumbnail image that is linked to the audio clip. |
video | bb-mode-video | The player is playing a video. |
live-audio | bb-mode-live-audio | The player is playing live audio and some features might not be available (e.g. getDuration()). |
live-video | bb-mode-live-video | The player is playing live video and some features might not be available (e.g. getDuration()). |
presentation | bb-mode-presentation | The player is showing a presentation. |
Example: When the mode changes to audio, set the volume to 100%.
player.on('modechange', function(){
if(player.getMode() == 'audio'){
player.setVolume(1);
}
});3.0 | Phases
In the process of playing content, the player goes through different phases. The current phase can be retrieved by calling getPhase(). The event phasechange is fired when the phase changes.
| Phase name | Class | Description |
|---|---|---|
INIT | bb-phase-init | The player has initialized and is waiting to play. |
PRE | bb-phase-pre | The player is playing a pre-content item, like a pre-roll commercial. The player will go through the PRE phase even if no pre-roll ad is configured or available. |
MAIN | bb-phase-main | The main content is being played. |
POST | bb-phase-post | The player is playing a post-content item, like a post-roll commercial. The player will go through the POST phase even if no post-roll ad is configured or available. |
EXIT | bb-phase-exit | The player has finished playing all content and has arrived in the exit phase. The exit screen can be shown here. |
Example: When the player reaches the EXIT phase, retract from fullscreen.
player.on('phasechange', function(){
if(player.getPhase() == 'EXIT'){
player.retractFullscreen();
}
});4.0 | States
States describe the current condition of the video content. The current state can be retrieved by calling getState(). The statechange event is fired whenever the state changes.
| State name | Class | Description |
|---|---|---|
idle | bb-state-idle | The player is idle and has not yet started playing. |
playing | bb-state-playing | The player is playing. |
paused | bb-state-paused | The player is paused. |
loading | bb-state-loading | The player is loading. |
error | bb-state-error | The player has encountered an error. |
Example: If the player has encountered an error, display an error element.
player.on('statechange', function(){
if(player.getState() == 'error'){
myErrorIcon.show();
}
});Or display an error element directly on the error event:
player.on('error', function(){
myErrorIcon.show();
});5.0 | Other useful classes
| Name | Class | Description |
|---|---|---|
fullscreen | bb-fullscreen | The player is now fullscreen. |
pending play | bb-pendingplay | The player has received a play call, but has not yet thrown the playing event. |
stalled | bb-stalled | The player has stalled due to buffering. |