Global

Members

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 srcDescriptorPolyfill

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

Methods

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
Parameters:
Name Type Description
tech Html5

The tech object that sourceset is being setup on.

get()

Calls a getter on the tech first, through each middleware from right to left to the player.

getDescriptor()

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

getOrCreateFactory()

{ [playerId]: [[mwFactory, mwInstance], ...] }

isPromise(value) → {Boolean}

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

Parameters:
Name Type Description
value Object

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

Returns:
Boolean -

Whether or not the object is Promise-like.

mediate()

Takes the argument given to the player and calls the call version of the method on each middleware from left to right. Then, call the passed in method on the tech and return the result unchanged back to the player, through middleware, this time from right to left.

module:merge-options(sources) → {Object}

Deep-merge one or more options objects, recursively merging only plain object properties.

Parameters:
Name Type Description
sources Array.<Object>

One or more objects to merge into a new object.

Returns:
Object -

A new object that is the merged result of all sources.

set()

Takes the argument given to the player and calls the setter method on each middleware from left to right to the tech.

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.

Parameters:
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.

Parameters:
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.

Parameters:
Name Type Description
tech Html5

The tech object that sourceset was setup on

Returns:
boolean -

returns false if the sourceset was not fired and true otherwise.