middleware.js
- Source
Members
(static, constant) allowedGetters :Object
Enumeration of allowed getters where the keys are method names.
- Object
- Source
(static, constant) allowedMediators :Object
Enumeration of allowed mediators where the keys are method names.
- Object
- Source
(static, constant) allowedSetters :Object
Enumeration of allowed setters where the keys are method names.
- Object
- Source
(inner, constant) middlewares
- Source
Methods
(static) clearCacheForPlayer(player)
Clear the middleware cache for a player.
- Source
(static) get(middleware, tech, method) → {*}
Calls a getter on the tech first, through each middleware from right to left to the player.
Name | Type | Description |
---|---|---|
middleware | Array.<Object> | An array of middleware instances. |
tech | Tech | The current tech. |
method | string | A method name. |
- Source
The final value from the tech after middleware has intercepted it.
- Type:
- *
(static) getMiddleware(type) → {Array.<function()>|undefined}
Gets middlewares by type (or all middlewares).
Name | Type | Description |
---|---|---|
type | string | The MIME type to match or |
- Source
An array of middlewares or undefined
if none exist.
- Type:
- Array.<function()> |
undefined
(static) mediate(middleware, tech, method, arg) → {*}
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.
Name | Type | Description |
---|---|---|
middleware | Array.<Object> | An array of middleware instances. |
tech | Tech | The current tech. |
method | string | A method name. |
arg | * | The value to set on the tech. |
- Source
The return value of the method
of the tech
, regardless of the return values of middlewares.
- Type:
- *
(static) set(middleware, tech, method, arg) → {*}
Takes the argument given to the player and calls the setter method on each middleware from left to right to the tech.
Name | Type | Description |
---|---|---|
middleware | Array.<Object> | An array of middleware instances. |
tech | Tech | The current tech. |
method | string | A method name. |
arg | * | The value to set on the tech. |
- Source
The return value of the method
of the tech
.
- Type:
- *
(static) setSource(player, src, The)
Asynchronously sets a source using middleware by recursing through any matching middlewares and calling setSource
on each, passing along the previous returned value each time.
Name | Type | Description |
---|---|---|
player | Player | A Player instance. |
src | Tech~SourceObject | A source object. |
The | function | next middleware to run. |
- Source
(static) setTech(middleware, tech)
When the tech is set, passes the tech to each middleware's setTech
method.
Name | Type | Description |
---|---|---|
middleware | Array.<Object> | An array of middleware instances. |
tech | Tech | A Video.js tech. |
- Source
(static) use(type, middleware)
Define a middleware that the player should use by way of a factory function that returns a middleware object.
Name | Type | Description |
---|---|---|
type | string | The MIME type to match or |
middleware | MiddlewareFactory | A middleware factory function that will be executed for matching types. |
- Source
Type Definitions
MiddlewareFactory(player)
A middleware factory function that should return a MiddlewareObject.
This factory will be called for each player when needed, with the player passed in as an argument.
Name | Type | Description |
---|---|---|
player | Player | A Video.js player. |
- Source
MiddlewareObject
A middleware object is a plain JavaScript object that has methods that match the Tech methods found in the lists of allowed getters, setters, and mediators.
- Object
- Source