OpenTV Player Web HTML5

Global

Members

constant darkGray

constant defaults

constant defaultsTransientButtonOptions

constant findMimetype

Find the mime type of a given source string if possible. Uses the player source cache.

constant getMimetype

Get the mimetype of a given src url if possible

constant innerHTMLDescriptorPolyfill

our implementation of an innerHTML descriptor for browsers that do not have one.

constant LOCAL_STORAGE_KEY

constant srcDescriptorPolyfill

our implementation of a src descriptor for browsers that do not have one

constant STEP_SECONDS

Methods

constructColor(color, opacity){string}

Construct an rgba color from a given hex color code.

Name Type Description
color number

Hex number for color, like #f0e or #f604e2.

opacity number

Value for opacity, 0.0 - 1.0.

Returns:
Type Description
string The rgba color that was created, like 'rgba(255, 0, 0, 0.3)'.

firstSourceWatch(tech)

Patches browser internal functions so that we can tell synchronously if a <source> was appended to the media element. For some reason this causes a sourceset if the the media element is ready and has no source. This happens when:

  • The page has just loaded and the media element does not have a source.
  • The media element was emptied of all sources, then load() was called.

It does this by patching the following functions/properties when they are supported:

  • append() - can be used to add a <source> element to the media element
  • appendChild() - can be used to add a <source> element to the media element
  • insertAdjacentHTML() - can be used to add a <source> element to the media element
  • innerHTML - can be used to add a <source> element to the media element
Name Type Description
tech Html5

The tech object that sourceset is being setup on.

getDescriptor()

Get a property descriptor given a list of priorities and the property to get.

hasPlugin(name){boolean}

Reports whether or not a player has a plugin available.

This does not report whether or not the plugin has ever been initialized on this player. For that, usingPlugin.

Name Type Description
name string

The name of a plugin.

Returns:
Type Description
boolean Whether or not this player has the requested plugin available.

hook(type, The)

Add a function hook to a specific videojs lifecycle.

Name Type Description
type string

the lifecycle to hook the function to.

The function | Array.<function()>

function or array of functions to attach.

hookOnce(type, The)

Add a function hook that will only run once to a specific videojs lifecycle.

Name Type Description
type string

the lifecycle to hook the function to.

The function | Array.<function()>

function or array of functions to attach.

hooks(type, fn){Array}

Get a list of hooks for a specific lifecycle

Name Type Description
type string

the lifecycle to get hooks from

fn function | Array.<function()> optional

Optionally add a hook (or hooks) to the lifecycle that your are getting.

Returns:
Type Description
Array an array of hooks, or an empty array if there are none.

isActuallyDisabled(element){boolean}

Decide whether an element is actually disabled or not.

Name Type Description
element Node
See:
Returns:
Type Description
boolean

isBeingRendered(element){boolean}

Decide whether the element is being rendered or not.

  1. If an element has the style as "visibility: hidden | collapse" or "display: none", it is not being rendered.
  2. If an element has the style as "opacity: 0", it is not being rendered.(that is, invisible).
  3. If width and height of an element are explicitly set to 0, it is not being rendered.
  4. If a parent element is hidden, an element itself is not being rendered. (CSS visibility property and display property are inherited.)
Name Type Description
element Node
See:
Returns:
Type Description
boolean

isExpresslyInert(element){boolean}

Decide whether the element is expressly inert or not.

Name Type Description
element Node
See:
Returns:
Type Description
boolean

isPromise(value){boolean}

Returns whether an object is Promise-like (i.e. has a then method).

Name Type Description
value Object

An object that may or may not be Promise-like.

Returns:
Type Description
boolean Whether or not the object is Promise-like.

isVisible(element){boolean}

Determine if the element is visible for the user or not.

  1. If an element sum of its offsetWidth, offsetHeight, height and width is less than 1 is not visible.
  2. If elementCenter.x is less than is not visible.
  3. If elementCenter.x is more than the document's width is not visible.
  4. If elementCenter.y is less than 0 is not visible.
  5. If elementCenter.y is the document's height is not visible.
Name Type Description
element Node
Returns:
Type Description
boolean

isVisibleStyleProperty(element){boolean}

Decide the style property of this element is specified whether it's visible or not.

Name Type Description
element CSSStyleDeclaration
Returns:
Type Description
boolean

percentify()

removeHook(type, fn){boolean}

Remove a hook from a specific videojs lifecycle.

Name Type Description
type string

the lifecycle that the function hooked to

fn function

The hooked function to remove

Returns:
Type Description
boolean The function that was removed or undef

setupSourceset(tech)

setup sourceset handling on the Html5 tech. This function patches the following element properties/functions:

  • src - to determine when src is set
  • setAttribute() - to determine when src is set
  • load() - this re-triggers the source selection algorithm, and can cause a sourceset.

If there is no source when we are adding sourceset support or during a load() we also patch the functions listed in firstSourceWatch.

Name Type Description
tech Html5

The tech to patch

silencePromise(value)

Silence a Promise-like object.

This is useful for avoiding non-harmful, but potentially confusing "uncaught play promise" rejection error messages.

Name Type Description
value Object

An object that may or may not be Promise-like.

sourcesetLoad(tech){boolean}

This function is used to fire a sourceset when there is something similar to mediaEl.load() being called. It will try to find the source via the src attribute and then the <source> elements. It will then fire sourceset with the source that was found or empty string if we cannot know. If it cannot find a source then sourceset will not be fired.

Name Type Description
tech Html5

The tech object that sourceset was setup on

Returns:
Type Description
boolean returns false if the sourceset was not fired and true otherwise.

Type Definitions

EventCustomEvent

A Custom DOM event.

See:

EventListener(event, hash)

All event listeners should follow the following format.

This:
Name Type Description
event Event

the event that triggered this function

hash Object optional

hash of data sent during the event

PlayerReadyCallback(){void}

This:
Returns:
Type Description
void

PlayerVersionObject

An object that contains Video.js version.

Properties:
Name Type Description
'video.js' string

Video.js version

PluginEventHashObject

Properties:
Name Type Description
instance string

For basic plugins, the return value of the plugin function. For advanced plugins, the plugin instance on which the event is fired.

name string

The name of the plugin.

plugin string

For basic plugins, the plugin function. For advanced plugins, the plugin class/constructor.

ReadyCallback(){void}

A callback to be called if and when the component is ready. this will be the Component instance.

Returns:
Type Description
void

SourceObjectObject string

An Object containing a structure like: {src: 'url', type: 'mimetype', startTime: seconds} or string that just contains the src url alone.

  • var SourceObject = {src: 'http://ex.com/video.mp4', type: 'video/mp4', startTime: 15};
  • var SourceString = 'http://example.com/some-video.mp4';
Properties:
Name Type Argument Default Description
src string

The url to the source

type string

The mime type of the source

token string <optional>

The content token for the source for DRM if required

preferredDRM string <optional>
"com.widevine.alpha"

The preferred DRM system to use if more than one is available

lowLatencyEnabled boolean <optional>
false

Enabled Low Latency mode if the source supports it

startAtLowestBitrate boolean <optional>
false

To reduce zap time indicate the desire to start at the lowest bitrate available

retainPreviousAsPreload boolean <optional>
false

To reduce zap time back to the previous source, indicate the desire to retain the previous source as a preload.

startTime number <optional>

The time at which the source starts playback in seconds. Infinity is a valid value to start at the end.

TransientButtonOptionsobject

Properties:
Name Type Argument Default Description
controlText string <optional>

Control text, usually visible for these buttons

initialDisplay number <optional>
4000

Time in ms that button should initially remain visible

position Array.<('top'|'neartop'|'bottom'|'left'|'right')> <optional>

Array of position strings to add basic styles for positioning

className string <optional>

Class(es) to add

takeFocus boolean <optional>
false

Whether element sohuld take focus when shown

clickHandler function <optional>

Function called on button activation

Events

pipoff

Event fired when video window is restored from small PIP window to full size

pipon

Event fired when video window is reduced to small PIP window

Type:
  • object