Module

mediaManager

This is a reimplementation of mediaManager with the support of dynamic import. The business logic will remain largely the same except the RequireJS module definition, and associated loading logic will be replaced with ES6 Promise, async and await to aid reading.

Members

Object.<string, Media>

# inner constant MediaList

A map of Media instance(s).

Object.<string, Promise>

# inner constant MediaPromiseList

A temporary map of Media creating Promise(s). The promise associated with media creation will be added to this object temporary, and the reference will be removed once the creation is finished, whether succeed or not.

Array.<String>

# inner constant PREPARED_PLAYER_IDS

An array of Player ID(s) that has already been prepared.

Methods

# async inner canCreatePlayer(importer) → {Promise.<Boolean>}

Check if it is possible to create a new instance of player by comparing the number of instance stored in player registry and the static MAX COUNT property of the Player imported by the importer specified.

Parameters:
Name Type Description
importer function

Importer function of the player class to be checked.

Native Promise.

Promise.<Boolean>

# async inner createMedia(id) → {Promise.<Media>}

Create a Media instance based on the ID provided. The Media instance will be stored in the MediaList and the corresponding reference will be removed from MediaPromiseList.

Parameters:
Name Type Description
id String

ID of the Media instance.

Native Promise.

Promise.<Media>

# async inner createPlayer(config) → {Promise.<Player>}

Create a new Player instance, and the associated Extension Manager instance, based on the configuration provided.

Parameters:
Name Type Description
config PlayerConfig

Configuration for creating the player instance.

Native Promise, wrapping a new instance of the player, with a new instance of Extension Manager attached.

Promise.<Player>

# async inner preparePlayerList(playerConfig) → {Promise.<void>}

Prepare the list of players using the config.

Parameters:
Name Type Description
playerConfig Array.<PlayerConfig>

An array of PlayerConfig that defines the player implementations.

Native Promise.

Promise.<void>

Type Definitions

Object

# ExtensionConfig

Extension definition.

Properties:
Name Type Attributes Description
type String

a unique string to identify the type of the extension.

importer function

The function, when executed, will return a promise for the module specified. That means () => import("module-namespace");

config Object <optional>

Optional configuration object for the specific extension.

Object

# PlayerConfig

Player configuration.

Properties:
Name Type Description
id String

A unique string to identify a player definition.

importer function

The function, when executed, will return a promise for the module specified. That means () => import("module-namespace");

extensions Array.<ExtensionConfig>

An array of configuration of the extension associated with the player.