new Plugin(player)
Creates an instance of this class.
Sub-classes should call super to ensure plugins are properly initialized.
| Name | Type | Description |
|---|---|---|
player |
Player |
A Video.js player instance. |
Fires:
- Player#event:beforepluginsetup
- Player#beforepluginsetup:$name
- Player#event:pluginsetup
- Player#pluginsetup:$name
Listens to Events:
Throws:
| Type | When |
|---|---|
| Error |
If attempting to instantiate the base |
Mixes In
Members
-
static Plugin.BASE_PLUGIN_NAMEstring
-
The name of the base plugin class as it is registered.
-
stateObject
-
A hash containing arbitrary keys and values representing the state of the object.
-
stateObject
-
A hash containing arbitrary keys and values representing the state of the object.
Methods
-
staticPlugin.deregisterPlugin(name)
-
De-register a Video.js plugin.
Name Type Description namestring The name of the plugin to be de-registered. Must be a string that matches an existing plugin.
Throws:
Type When Error If an attempt is made to de-register the base plugin.
-
staticPlugin.getPlugin(name)
-
Gets a plugin by name if it exists.
Name Type Description namestring The name of a plugin.
Returns:
-
staticPlugin.getPlugins(names){Object|undefined}
-
Gets an object containing multiple Video.js plugins.
Name Type Description namesArray optional If provided, should be an array of plugin names. Defaults to all plugin names.
Returns:
Type Description Object | undefined An object containing plugin(s) associated with their name(s) or undefinedif no matching plugins exist). -
staticPlugin.getPluginVersion(name){string}
-
Gets a plugin's version, if available
Name Type Description namestring The name of a plugin.
Returns:
Type Description string The plugin's version or an empty string. -
staticPlugin.isBasic(plugin){boolean}
-
Determines if a plugin is a basic plugin (i.e. not a sub-class of
Plugin).Name Type Description pluginstring | function If a string, matches the name of a plugin. If a function, will be tested directly.
Returns:
Type Description boolean Whether or not a plugin is a basic plugin. -
staticPlugin.registerPlugin(name, plugin)
-
Register a Video.js plugin.
Name Type Description namestring The name of the plugin to be registered. Must be a string and must not match an existing plugin or a method on the
Playerprototype.pluginReturns:
-
any(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object. The listener will only be called once for the first event that is triggered then removed.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
any(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object. The listener will only be called once for the first event that is triggered then removed.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
dispose()
-
Disposes a plugin.
Subclasses can override this if they want, but for the sake of safety, it's probably best to subscribe the "dispose" event.
Fires:
-
getEventHash(hash){PluginEventHash}
-
Each event triggered by plugins includes a hash of additional data with conventional properties.
This returns that object or mutates an existing hash.
Name Type Default Description hashObject {} optional An object to be used as event an event hash.
Returns:
Type Description PluginEventHash An event hash object with provided properties mixed-in. -
abstracthandleStateChanged(e)
-
Handles "statechanged" events on the plugin. No-op by default, override by subclassing.
Name Type Description eEvent An event object provided by a "statechanged" event.
Name Type Description changesObject An object describing changes that occurred with the "statechanged" event.
-
off(targetOrType, typeOrListener, listener)
-
Removes listener(s) from event(s) on an evented object.
Name Type Description targetOrTypestring | Array | Element | Object optional If this is a string or array, it represents the event type(s).
Another evented object can be passed here instead, in which case ALL 3 arguments are _required_.typeOrListenerstring | Array | function optional If the first argument was a string or array, this may be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function; otherwise, all listeners bound to the event type(s) will be removed.
-
off(targetOrType, typeOrListener, listener)
-
Removes listener(s) from event(s) on an evented object.
Name Type Description targetOrTypestring | Array | Element | Object optional If this is a string or array, it represents the event type(s).
Another evented object can be passed here instead, in which case ALL 3 arguments are _required_.typeOrListenerstring | Array | function optional If the first argument was a string or array, this may be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function; otherwise, all listeners bound to the event type(s) will be removed.
-
on(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
on(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
one(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object. The listener will be called once per event and then removed.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
one(targetOrType, typeOrListener, listener)
-
Add a listener to an event (or events) on this object or another evented object. The listener will be called once per event and then removed.
Name Type Description targetOrTypestring | Array | Element | Object If this is a string or array, it represents the event type(s) that will trigger the listener.
Another evented object can be passed here instead, which will cause the listener to listen for events on _that_ object. In either case, the listener's `this` value will be bound to this object.typeOrListenerstring | Array | function If the first argument was a string or array, this should be the listener function. Otherwise, this is a string or array of event type(s).
listenerfunction optional If the first argument was another evented object, this will be the listener function.
-
setState(stateUpdates){Object|undefined}
-
Set the state of an object by mutating its
stateobject in place.Name Type Description stateUpdatesObject | function A new set of properties to shallow-merge into the plugin state. Can be a plain object or a function returning a plain object.
Fires:
Returns:
Type Description Object | undefined An object containing changes that occurred. If no changes occurred, returns undefined. -
setState(stateUpdates){Object|undefined}
-
Set the state of an object by mutating its
stateobject in place.Name Type Description stateUpdatesObject | function A new set of properties to shallow-merge into the plugin state. Can be a plain object or a function returning a plain object.
Fires:
Returns:
Type Description Object | undefined An object containing changes that occurred. If no changes occurred, returns undefined. -
trigger(event, hash){boolean}
-
Triggers an event on the plugin object and overrides
EventedMixin.trigger.Name Type Default Description eventstring | Object An event type or an object with a type property.
hashObject {} optional Additional data hash to merge with a
PluginEventHash.Returns:
Type Description boolean Whether or not default was prevented. -
trigger(event, hash){boolean}
-
Fire an event on this evented object, causing its listeners to be called.
Name Type Description eventstring | Object An event type or an object with a type property.
hashObject optional An additional object to pass along to listeners.
Returns:
Type Description boolean Whether or not the default behavior was prevented. -
trigger(event, hash){boolean}
-
Fire an event on this evented object, causing its listeners to be called.
Name Type Description eventstring | Object An event type or an object with a type property.
hashObject optional An additional object to pass along to listeners.
Returns:
Type Description boolean Whether or not the default behavior was prevented. -
version()
-
Get the version of the plugin that was set on
.VERSION
Events
-
dispose
-
Signals that a advanced plugin is about to be disposed.
Type: