1. Home
  2. Developers
  3. Player API
  4. Events, Modes and Phases

Events, Modes and Phases


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 nameDescriptionRelated API function
loadMedia data loading started
loadeddataMedia data was loaded
loadedmetadataMedia metadata was loaded
canplayThe player is now ready to play.play()
playThe player has executed a play command.
pauseThe player is now paused.
playingThe player is now playing.
seekingThe player is now seeking.
seekedThe current playback position has changed by the player as a result of a seek action.
endedPlayback has stopped because the end of the media resource was reached.
startedThe player has started for the first time. This event happens at most once during a player session.
timeupdateThe 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()
stalledThe player is trying to fetch new media data, but is unable to retrieve it and continue playing.
unstalledThe player is able to continue playing.
progressThe buffer has been updated by the player.getBuffered()
errorThe player has encountered an error which prevents it from playing the content further.
aderrorThe advertisement provider encountered an error which prevents the ad from playing in the player.
adnotfoundThe 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 nameDescriptionRelated API function
loadedplayoutdataPlayout data is loaded.getPlayoutData()
changedplayoutdataPlayout data changed.getPlayoutData()
loadedclipdataClip data is loaded.getClipData()
loadedcliplistdataClip list data is loaded.
changedcliplistdataClip list data has changed.
loadedprojectdataProject data is loaded.getProjectData()
loadedinteractivityInteractive content has been loaded.
chapterlistchangeThe list of chapters has changed.getChapterList()
highlightlistchangeThe list of highlights has changed.
relatedclipschangeThe list of related clips has been loaded or changed.getRelatedList()
assetlistchangeThe list of assets has changed.getAssets()
audiotracklistchangeThe list of audio tracks has changed.getAudioTracks()
texttracklistchangeThe list of text tracks has changed.
transcriptlistchangeThe list of transcripts has changed.
transcriptchangeThe active transcript has changed.
durationchangeThe 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 nameDescriptionRelated API function
modechangeThe mode has changed. The wrapper class bb-mode-{mode} has also changed.getMode()
statechangeThe state has changed. The wrapper class bb-state-{state} has also changed.getState()
phasechangeThe phase has changed. The wrapper class bb-phase-{phase} has also changed.getPhase()
flagchangeA flag has changed.getFlag(flagname)
Event nameDescription
adstartedAn ad has started.
adquartile1An ad has reached its first quartile.
adquartile2An ad has reached its second quartile.
adquartile3An ad has reached its third quartile.
adfinishedAn ad has finished.
adskippableAn ad has become skippable.
adclickedThe user has clicked on an ad.

1.5 | Autoplay Next Events

Event nameDescription
autoplaynexttimerstartedThe AutoPlayNext timer has started.
autoplaynexttimercancelledThe AutoPlayNext timer was cancelled.
autoplaynexttimertickThe AutoPlayNext timer has ticked.
autoplaynexttimerfinishedThe AutoPlayNext timer has finished.
autoplaynexttimerpausedThe AutoPlayNext timer has paused.
autoplaynexttimerresumedThe AutoPlayNext timer has resumed.

1.6 | Soft Embargo Timer Events

Event nameDescription
softembargotimerstartedThe soft embargo timer has started.
softembargotimertickThe soft embargo timer has ticked.
softembargotimerfinishedThe soft embargo timer has finished.
softembargotimercancelledThe soft embargo timer was cancelled.

1.7 | General Events

Event nameDescriptionRelated API function
readyThe player API is ready and functions can be called from the API.
assetselectedA different asset has been selected by the player.getCurrentAsset()
audiotrackchangeA different audio track was selected by the player.getCurrentAudiotrack()
volumechangeThe volume has changed.getVolume()
subtitlechangeThe subtitle language has changed.getCurrentSubtitle()
subtitlelinechangeThe current subtitle line has changed.getCurrentSubtitleLine()
resizedThe player size has been changed.
inviewThe player is now inside the user agent’s viewport.
outviewThe player is now outside the user agent’s viewport.
fullscreenThe player is now fullscreen.
retractfullscreenThe player is now not fullscreen.
floatstartThe player initiated floating behaviour.
floatendThe player stopped floating behaviour.
autopauseThe player was automatically paused (e.g. when scrolled out of view).
contentblockedContent playback was blocked (e.g. due to geo-restriction or age-gating).
castsessionchangeThe cast session has changed.
collapsedThe player UI has collapsed.
expandedThe player UI has expanded.
fullscreenmismatchA mismatch was detected between the player’s fullscreen state and the browser’s.
fullscreenmismatchresolvedA 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 nameClassDescription
staticbb-mode-staticThe player has static content loaded, such as an image, a document, or interactive content.
commercialbb-mode-commercialThe player is playing a VMS creative, VAST source or any other commercial.
audiobb-mode-audioThe player is playing audio only content. Note: The player can still display a thumbnail image that is linked to the audio clip.
videobb-mode-videoThe player is playing a video.
live-audiobb-mode-live-audioThe player is playing live audio and some features might not be available (e.g. getDuration()).
live-videobb-mode-live-videoThe player is playing live video and some features might not be available (e.g. getDuration()).
presentationbb-mode-presentationThe 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 nameClassDescription
INITbb-phase-initThe player has initialized and is waiting to play.
PREbb-phase-preThe 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.
MAINbb-phase-mainThe main content is being played.
POSTbb-phase-postThe 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.
EXITbb-phase-exitThe 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 nameClassDescription
idlebb-state-idleThe player is idle and has not yet started playing.
playingbb-state-playingThe player is playing.
pausedbb-state-pausedThe player is paused.
loadingbb-state-loadingThe player is loading.
errorbb-state-errorThe 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

NameClassDescription
fullscreenbb-fullscreenThe player is now fullscreen.
pending playbb-pendingplayThe player has received a play call, but has not yet thrown the playing event.
stalledbb-stalledThe player has stalled due to buffering.

Was this article helpful?

Related Articles

Contact Support
Can't find the answer you're looking for?
Contact Support