Constructor
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. |
If attempting to instantiate the base Plugin class directly instead of via a sub-class.
- Type
- Error
Members
(static) BASE_PLUGIN_NAME :string
The name of the base plugin class as it is registered.
- string
state :Object
A hash containing arbitrary keys and values representing the state of the object.
- Object
- Source
state :Object
A hash containing arbitrary keys and values representing the state of the object.
- Object
- Source
Methods
(static) deregisterPlugin(name)
De-register a Video.js plugin.
Name | Type | Description |
---|---|---|
name | string | The name of the plugin to be de-registered. Must be a string that matches an existing plugin. |
If an attempt is made to de-register the base plugin.
- Type
- Error
(static) getPlugin(name) → {Class.<Plugin>|function|undefined}
Gets a plugin by name if it exists.
Name | Type | Description |
---|---|---|
name | string | The name of a plugin. |
The plugin (or undefined
).
- Type:
- Class.<Plugin> |
function | undefined
(static) getPlugins(namesopt) → {Object|undefined}
Gets an object containing multiple Video.js plugins.
Name | Type | Attributes | Description |
---|---|---|---|
names | Array | <optional> | If provided, should be an array of plugin names. Defaults to all plugin names. |
An object containing plugin(s) associated with their name(s) or undefined
if no matching plugins exist).
- Type:
- Object |
undefined
(static) getPluginVersion(name) → {string}
Gets a plugin's version, if available
Name | Type | Description |
---|---|---|
name | string | The name of a plugin. |
The plugin's version or an empty string.
- Type:
- string
(static) isBasic(plugin) → {boolean}
Determines if a plugin is a basic plugin (i.e. not a sub-class of Plugin
).
Name | Type | Description |
---|---|---|
plugin | string | | If a string, matches the name of a plugin. If a function, will be tested directly. |
Whether or not a plugin is a basic plugin.
- Type:
- boolean
(static) registerPlugin(name, plugin) → {Class.<Plugin>|function}
Register a Video.js plugin.
Name | Type | Description |
---|---|---|
name | string | The name of the plugin to be registered. Must be a string and must not match an existing plugin or a method on the |
plugin | Class.<Plugin> | | A sub-class of |
For advanced plugins, a factory function for that plugin. For basic plugins, a wrapper function that initializes the plugin.
- Type:
- Class.<Plugin> |
function
any(targetOrType, typeOrListener, listeneropt)
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 | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
any(targetOrType, typeOrListener, listeneropt)
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 | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
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.
getEventHash(hashopt) → {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 | Attributes | Default | Description |
---|---|---|---|---|
hash | Object | <optional> | {} | An object to be used as event an event hash. |
An event hash object with provided properties mixed-in.
- Type:
- PluginEventHash
(abstract) handleStateChanged(e)
Handles "statechanged" events on the plugin. No-op by default, override by subclassing.
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
e | Event | An event object provided by a "statechanged" event. Properties
|
off(targetOrTypeopt, typeOrListeneropt, listeneropt)
Removes listener(s) from event(s) on an evented object.
Name | Type | Attributes | Description |
---|---|---|---|
targetOrType | string | | <optional> | If this is a string or array, it represents the event type(s).
|
typeOrListener | string | | <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). |
listener | function | <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. |
- Mixes In
- Source
off(targetOrTypeopt, typeOrListeneropt, listeneropt)
Removes listener(s) from event(s) on an evented object.
Name | Type | Attributes | Description |
---|---|---|---|
targetOrType | string | | <optional> | If this is a string or array, it represents the event type(s).
|
typeOrListener | string | | <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). |
listener | function | <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. |
- Mixes In
- Source
on(targetOrType, typeOrListener, listeneropt)
Add a listener to an event (or events) on this object or another evented object.
Name | Type | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
on(targetOrType, typeOrListener, listeneropt)
Add a listener to an event (or events) on this object or another evented object.
Name | Type | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
one(targetOrType, typeOrListener, listeneropt)
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 | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
one(targetOrType, typeOrListener, listeneropt)
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 | Attributes | Description |
---|---|---|---|
targetOrType | string | | If this is a string or array, it represents the event type(s) that will trigger the listener.
| |
typeOrListener | string | | 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). | |
listener | function | <optional> | If the first argument was another evented object, this will be the listener function. |
- Mixes In
- Source
setState(stateUpdates) → {Object|undefined}
Set the state of an object by mutating its state object in place.
Name | Type | Description |
---|---|---|
stateUpdates | Object | | A new set of properties to shallow-merge into the plugin state. Can be a plain object or a function returning a plain object. |
- Source
An object containing changes that occurred. If no changes occurred, returns undefined
.
- Type:
- Object |
undefined
setState(stateUpdates) → {Object|undefined}
Set the state of an object by mutating its state object in place.
Name | Type | Description |
---|---|---|
stateUpdates | Object | | A new set of properties to shallow-merge into the plugin state. Can be a plain object or a function returning a plain object. |
- Source
An object containing changes that occurred. If no changes occurred, returns undefined
.
- Type:
- Object |
undefined
trigger(event, hashopt) → {boolean}
Triggers an event on the plugin object and overrides EventedMixin.trigger.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event | string | | An event type or an object with a type property. | ||
hash | Object | <optional> | {} | Additional data hash to merge with a PluginEventHash. |
Whether or not default was prevented.
- Type:
- boolean
trigger(event, hashopt) → {boolean}
Fire an event on this evented object, causing its listeners to be called.
Name | Type | Attributes | Description |
---|---|---|---|
event | string | | An event type or an object with a type property. | |
hash | Object | <optional> | An additional object to pass along to listeners. |
- Source
Whether or not the default behavior was prevented.
- Type:
- boolean
trigger(event, hashopt) → {boolean}
Fire an event on this evented object, causing its listeners to be called.
Name | Type | Attributes | Description |
---|---|---|---|
event | string | | An event type or an object with a type property. | |
hash | Object | <optional> | An additional object to pass along to listeners. |
- Source
Whether or not the default behavior was prevented.
- Type:
- boolean
version()
Get the version of the plugin that was set on
Events
dispose
Signals that a advanced plugin is about to be disposed.