middleware.js
Members
-
static,constant module:middleware.allowedGettersObject
-
Enumeration of allowed getters where the keys are method names.
-
static,constant module:middleware.allowedMediatorsObject
-
Enumeration of allowed mediators where the keys are method names.
-
static,constant module:middleware.allowedSettersObject
-
Enumeration of allowed setters where the keys are method names.
Methods
-
staticmodule:middleware.clearCacheForPlayer(player)
-
Clear the middleware cache for a player.
Name Type Description playerPlayer A
Playerinstance. -
staticmodule:middleware.get(middleware, tech, method){Mixed}
-
Calls a getter on the tech first, through each middleware from right to left to the player.
Name Type Description middlewareArray.<Object> An array of middleware instances.
techTech The current tech.
methodstring A method name.
Returns:
Type Description Mixed The final value from the tech after middleware has intercepted it. -
staticmodule:middleware.getMiddleware(type){Array.<function()>|undefined}
-
Gets middlewares by type (or all middlewares).
Name Type Description typestring The MIME type to match or
"*"for all MIME types.Returns:
Type Description Array.<function()> | undefined An array of middlewares or undefinedif none exist. -
staticmodule:middleware.mediate(middleware, tech, method, arg){Mixed}
-
Takes the argument given to the player and calls the
callversion 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 middlewareArray.<Object> An array of middleware instances.
techTech The current tech.
methodstring A method name.
argMixed The value to set on the tech.
Returns:
Type Description Mixed The return value of the methodof thetech, regardless of the return values of middlewares. -
staticmodule:middleware.set(middleware, tech, method, arg){Mixed}
-
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 middlewareArray.<Object> An array of middleware instances.
techTech The current tech.
methodstring A method name.
argMixed The value to set on the tech.
Returns:
Type Description Mixed The return value of the methodof thetech. -
staticmodule:middleware.setSource(player, src, The)
-
Asynchronously sets a source using middleware by recursing through any matching middlewares and calling
setSourceon each, passing along the previous returned value each time.Name Type Description playerPlayer A
Playerinstance.srcTech~SourceObject A source object.
Thefunction next middleware to run.
-
staticmodule:middleware.setTech(middleware, tech)
-
When the tech is set, passes the tech to each middleware's
setTechmethod.Name Type Description middlewareArray.<Object> An array of middleware instances.
techTech A Video.js tech.
-
staticmodule:middleware.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 typestring The MIME type to match or
"*"for all MIME types.middlewareMiddlewareFactory A middleware factory function that will be executed for matching types.
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 playerPlayer A Video.js player.
-
MiddlewareObjectObject
-
A middleware object is a plain JavaScript object that has methods that match the
Techmethods found in the lists of allowedgetters,setters, andmediators.