Methods


Contents

The Blue Billywig Player API exposes a wide range of methods. The list below covers all methods that can be called on the player API object.

1.0 | Transport

1.1 | on(eventType, handler)

Attach an event handler for events fired by the player, in the same way as jQuery’s .on() does.

on( eventType, handler )

Arguments

KeyTypeValue
eventTypestringOne or more space-separated event types and optional namespaces.
handlerfunctionA function to execute when the event is triggered.
Note:

It is possible to add a namespace to eventType, and we encourage you to do so. This will prevent accidental detaching of event handlers by other applications using the same player API.

1.2 | off(eventType)

Detach an event handler from events fired by the player. Please refer to the jQuery documentation for more information.

off( eventType )

Arguments

KeyTypeValue
eventTypestringOne or more space-separated event types and optional namespaces.

1.3 | load(params)

Load a clip.

load( params )

Arguments

KeyTypeValue
typestring'LoadParams'
clipIdnumberClip ID from the VMS.
cliplistIdnumberClip list ID from the VMS.
xmlUrlstringURL to a valid XML playout file.
seekTonumberThe time at which the player should start playing, in seconds.
autoPlaybooleanWhether the player should autoplay when loaded.
tokenstringA session token to pass to the loaded clip.
useSessionbooleanWhether the player should use the browser session to load new clips.

1.4 | play(userAction)

Play the loaded video.

play( userAction )

Arguments

KeyTypeValue
userActionbooleantrue if called in response to a user action (optional).

Returns

TypeValue
booleanReturns true on success, false on failure.

1.5 | pause()

Pause the video.

pause()

Returns

TypeValue
booleanReturns true on success, false on failure.

1.6 | seek(positionInSeconds)

Seek the video to a specific position.

seek( positionInSeconds )

Arguments

KeyTypeValue
positionInSecondsnumberThe position to seek to, in seconds.

Returns

TypeValue
booleanReturns true on success, false on failure.

2.0 | Setters

2.1 | setVolume(volume)

Set the master volume, including any Picture-in-Picture widgets on the timeline.

setVolume( volume )

Arguments

KeyTypeValue
volumenumberA number between 0 and 1.

Returns

TypeValue
booleanReturns true on success, false on failure.

2.2 | setMuted(muted, reserved, userAction)

Set the master mute state, including any Picture-in-Picture widgets on the timeline.

setMuted( muted, reserved, userAction )

Arguments

KeyTypeValue
mutedbooleantrue to mute the player, false to unmute.
userActionbooleantrue if called in response to a user action (optional).

Returns

TypeValue
booleanReturns true on success, false on failure.

2.3 | setProgramVolume(volume)

Set the volume for the main video only.

setProgramVolume( volume )

Arguments

KeyTypeValue
volumenumberA number between 0 and 1.

Returns

TypeValue
booleanReturns true on success, false on failure.

2.4 | setAsset(assetId)

Switch the asset for the current video.

setAsset( assetId )

Arguments

KeyTypeValue
assetIdnumberAn asset ID matching one from getAssets().

Returns

TypeValue
booleanReturns true on success, false on failure.

2.5 | setFitMode(fitMode)

Fit mode settings determine how video content fits within the player when the aspect ratios differ. Read more about Fit mode settings.

setFitMode( fitMode )

Arguments

KeyTypeValue
fitModestringFIT_SMART, FIT_BOTH, FIT_OVERSCAN, FIT_NATIVE, FIT_STRETCH, FIT_VERTICAL, FIT_HORIZONTAL

Returns

TypeValue
booleanReturns true on success, false on failure.

2.6 | setLocalStorageItem(key, value)

Write an entry to LocalStorage, if permitted by the current cookie settings.

setLocalStorageItem( key, value )

Arguments

KeyTypeValue
keystringThe LocalStorage key.
valuestringThe value to store.

Returns

TypeValue
booleanReturns true on success, false on failure.

2.7 | setSubtitle(subtitleId)

Set the active subtitle track.

setSubtitle( subtitleId )

Arguments

KeyTypeValue
subtitleIdnumberThe subtitle ID, as found in the subtitle object returned by getSubtitlesList().

2.8 | setInView(inView)

Override the player’s in-view state.

setInView( inView )

Arguments

KeyTypeValue
inViewboolean?The forced in-view state, or null to remove the override.

2.9 | setRelatedItems(items)

Override the related items shown in the player.

setRelatedItems( items )

Arguments

KeyTypeValue
itemsarray?An array of content item objects, or null to clear.

Item object properties

KeyValue
idstring — Unique identifier of the media clip (required).
titlestring — Media clip title (optional).
typestring — Item type: "MediaClip", "Project", or "MediaClipList" (optional).
mediatypestring — Media type: "audio", "video", "interactive", "mainroll", or "image" (optional).
lengthinteger — Duration in seconds (optional).
sourcetypestring — Source type: "on_demand" or "live" (optional).
deeplinkstring — Deeplink URL of the item (optional).
gendeeplinkstring — Dynamically generated deeplink URL of the item (optional).

Example

playerAPI.setRelatedItems([
    { id: "1234567" },
    { id: "9876543" },
    { id: "3456789" }
]);

3.0 | Getters A – C

3.1 | getAssets()

Returns an array of asset objects available for the current clip on the current device.

getAssets()

Returns

TypeValue
arrayAn array of asset objects. See getCurrentAsset() for the object structure.

3.2 | getBuffered()

Returns the buffered ranges of the main clip. Multiple ranges can be buffered as a result of seeking.

getBuffered()

Returns

KeyTypeValue
startarrayStart positions of all buffered ranges, in seconds.
endarrayEnd positions of all buffered ranges, in seconds.
lengthnumberThe number of buffered ranges.

Example

var buffered = playerAPI.getBuffered();

for (var i = 0; i < buffered.length; i++) {
    var start = buffered.start[i];
    var end = buffered.end[i];
}

3.3 | getCastSource()

Returns the source URL for casting.

3.4 | getChapterList()

Returns an array of chapter objects set for the current clip in the Timeline editor.

getChapterList()

Returns

KeyTypeValue
idnumberThe ID of the chapter.
titlestringThe chapter title as set in the Timeline editor.
descriptionstringThe chapter description as set in the Timeline editor.
timeOffsetnumberThe time at which the chapter starts, in seconds.

3.5 | getClipData()

Returns all data for the current clip. Use the browser console to inspect the returned object:

console.log(playerAPI.getClipData());
Note:

The returned object is subject to change. Always check whether a property exists before using it.

if (typeof clipData.title !== 'undefined') {
    setTitle(clipData.title);
}

3.6 | getContentLayer()

Returns the content layer DOM element. Useful when resizing the content area (video, timeline, and subtitles) to show a description panel or related clips.

getContentLayer()

Returns

TypeValue
elementThe content layer DOM element.

3.7 | getCurrentAsset()

Returns an object describing the currently active asset.

getCurrentAsset()

Returns

KeyTypeValue
idnumberThe asset ID.
mediatypestringThe media type of the asset, e.g. MP4_MAIN or MP4_IPOD.
titlestringA label that can be used for a quality selector button.
bitratenumberThe bitrate of the asset.
classesstringCSS classes that can be applied to a quality selector button for this asset.
widthnumberThe width of the asset in pixels.
heightnumberThe height of the asset in pixels.

3.8 | getCurrentSubtitle()

Returns an object describing the currently active subtitle track.

getCurrentSubtitle()

Returns

KeyTypeValue
idnumberThe ID of the subtitle track.
languageidnumberThe language ID of the subtitle track.
namestringThe display name of the subtitle track (e.g. Dutch or German).
languagenamestringThe localised name of the subtitle track (e.g. Nederlands or Deutsch).
defaultbooleantrue if this is the default subtitle track, false otherwise.
isocodestringThe ISO 639-1 language code.
statusstringThe status of the subtitle track: published or draft.
parsedDataarrayAn array containing all subtitle lines.

3.9 | getCurrentSubtitleLine()

Returns the currently displayed subtitle line.

getCurrentSubtitleLine()

Returns

TypeValue
stringThe current subtitle line, which may contain HTML formatting.

3.10 | getCurrentTime()

Returns the current playback position of the main clip.

getCurrentTime()

Returns

TypeValue
numberThe current playback position in seconds.

4.0 | Getters D – L

Returns the deep link of the current clip as configured in the VMS.

getDeeplink()

Returns

TypeValue
stringThe formatted deep link URL.

4.2 | getDetections()

Returns the detections object. Refer to the detections documentation for available properties and methods.

4.3 | getDuration()

Returns the duration of the main clip.

getDuration()

Returns

TypeValue
numberThe duration in seconds. Returns null for static clips.

4.4 | getEmbedcode([width], [height])

Returns the embed code for the current clip, with an optional width and height override.

”getEmbedcode(

, [height] )” id=”” class=”” style=”” ]

Arguments

KeyTypeValue
widthnumberThe width in pixels of the embedded player (optional).
heightnumberThe height in pixels of the embedded player (optional).

Returns

TypeValue
stringA formatted embed code.

4.5 | isFullscreen()

Returns whether the player is currently in fullscreen mode.

isFullscreen()

Returns

TypeValue
booleantrue if the player is fullscreen, false otherwise.

4.6 | getLocalStorageItem(key)

Returns the value of a LocalStorage entry.

getLocalStorageItem( key )

Arguments

KeyTypeValue
keystringThe LocalStorage key.

Returns

TypeValue
mixedThe stored value, or undefined if the key does not exist.

Returns the logo configuration for the active playout.

getLogo()

Returns

KeyTypeValue
positionstringThe position of the logo, e.g. TOPRIGHT.
urlstringThe URL the logo links to.
srcstringThe URL of the logo image.
idstringThe ID of the clip used as the logo.

5.0 | Getters M – R

5.1 | getMode()

Returns the current mode of the player.

getMode()

Returns

TypeValue
stringOne of the following: static, commercial, audio, video, presentation, live-audio, live-video.

5.2 | getMuted()

Returns the current master mute state.

getMuted()

Returns

TypeValue
booleantrue if muted, false if unmuted.

5.3 | getPhase()

Returns the current phase of the player.

getPhase()

Returns

TypeValue
stringOne of the following: INIT, PRE, MAIN, POST, EXIT.

5.4 | isPlaying()

Returns whether the player is currently playing.

isPlaying()

Returns

TypeValue
booleantrue if the player is playing, false otherwise.

5.5 | getPlayoutData()

Returns all playout settings from the VMS. Similar to getClipData(), but returns playout-level data.

5.6 | getProjectData()

Returns all project metadata. Similar to getClipData(), but returns project-level data.

5.7 | getRelatedClips()

Returns an array of clip objects related to the active clip.

Note:

This method only returns data after the relatedclipschange event has been fired.

6.0 | Getters S – Z

6.1 | getSharing()

Returns an array of social sharing objects for the current clip.

getSharing()

Returns

KeyTypeValue
idnumberThe ID of the sharing item.
namestringA machine-readable identifier for the sharing channel.
titlestringA human-readable name for the sharing channel.
urlstringA formatted URL pointing to the share page of the social network.

6.2 | getSkinLayer()

Returns the skin container DOM element. Useful for finding HTML elements within the player skin.

getSkinLayer()

Returns

TypeValue
elementThe skin container DOM element.

6.3 | getSubtitleLayer()

Returns the subtitle layer DOM element. Useful when implementing custom subtitle rendering in the skin.

getSubtitleLayer()

Returns

TypeValue
elementThe subtitle container DOM element.

6.4 | getSubtitlesList()

Returns an array of subtitle track objects for the current clip.

getSubtitlesList()

Returns

TypeValue
arrayAn array of subtitle objects. See getCurrentSubtitle() for the object structure.

6.5 | getThumbnail(clipId, [width], [height])

Returns a URL to the thumbnail for a specified clip, optionally at a given size.

”getThumbnail(

, [height] )” id=”” class=”” style=”” ]

Arguments

KeyTypeValue
clipIdnumberThe clip ID.
widthnumberThe desired thumbnail width in pixels. Defaults to the original width (optional).
heightnumberThe desired thumbnail height in pixels. Defaults to the original height (optional).

Returns

TypeValue
stringThe URL of the thumbnail image.

6.6 | getVolume()

Returns the current master volume. Use this after a volumechange event to read the updated value.

getVolume()

Returns

TypeValue
numberThe master volume as a number between 0 and 1.

Example

playerAPI.on('volumechange', function(){
    var volume = playerAPI.getVolume();
});

playerAPI.setVolume(0.5);

6.7 | getWrapper()

Returns the player wrapper DOM element.

getWrapper()

Returns

TypeValue
elementThe wrapper DOM element.

7.0 | Interface

7.1 | showInterfaceElement(elementName)

Shows the specified interface element. Available elements:

  • controlBar
  • playPauseButton
  • progressBar
  • timeDisplay
  • muteButton
  • volumeSlider
  • languageButton
  • hdButton
  • fullscreenButton
  • shareButton
showInterfaceElement( elementName )

Arguments

KeyTypeValue
elementNamestringA valid element name (see list above).

7.2 | hideInterfaceElement(elementName)

Hides the specified interface element.

hideInterfaceElement( elementName )

Arguments

KeyTypeValue
elementNamestringA valid element name. See showInterfaceElement() for the list of available elements.

7.3 | enableInterfaceElement(elementName)

Enables the specified interface element.

enableInterfaceElement( elementName )

Arguments

KeyTypeValue
elementNamestringA valid element name. See showInterfaceElement() for the list of available elements.

7.4 | disableInterfaceElement(elementName)

Disables the specified interface element.

disableInterfaceElement( elementName )

Arguments

KeyTypeValue
elementNamestringA valid element name. See showInterfaceElement() for the list of available elements.

7.5 | showCastTargetPicker(type)

Shows the cast target picker, if available.

showCastTargetPicker( type )

Arguments

KeyTypeValue
typestringThe cast type: 'AirPlay' (default) or 'ChromeCast'.

8.0 | Miscellaneous

8.1 | fullscreen()

Enter fullscreen mode.

8.2 | retractFullscreen()

Exit fullscreen mode.

8.3 | toggleFullscreen()

Enters fullscreen mode when the player is not fullscreen, and exits fullscreen when it is.

8.4 | playAdTag(params)

Instructs the player to request and play an ad tag. When params.phase is set to "PRE" or "POST", the player requests the tag the next time it enters that phase. If multiple playAdTag calls are made for the same phase, the player works through each tag in order until one fills, then clears all tags for that phase.

When params.phase is "MAIN", the player will either:

  • Request the tag immediately and interrupt the content if it is currently in the MAIN phase and no time parameter was provided.
  • Schedule the request at the specified time offset and interrupt content when that offset is reached.
  • Schedule the request and interrupt content the moment the player starts playing, if it is not yet in the MAIN phase.
Note:

This method does not work if the player uses the Ad Schedules feature, or if ad units are already configured for the same phase.

playAdTag( params )

Arguments

KeyTypeValue
paramsobjectParameters object. Either params.vastUrl or params.vastXml is required.
params.phasestringThe phase in which to request the ad: "PRE", "MAIN", or "POST". Defaults to "MAIN".
params.timenumberTime offset in seconds within the MAIN phase at which the ad should be requested (optional).
params.vastUrlstringThe VAST URL to request. If both vastUrl and vastXml are provided, vastUrl takes precedence.
params.vastXmlstringThe VAST XML to request. If both vastUrl and vastXml are provided, vastUrl takes precedence.

Returns true if the request was successfully scheduled, false otherwise.

8.5 | destruct()

Destructs the player, freeing up memory and removing its elements from the DOM.

Was this article helpful?

Related Articles

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