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
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
(static) BASE_PLUGIN_NAME :string
The name of the base plugin class as it is registered.
- string
Methods
any(type, fn)
This function will add an event listener
that gets triggered only once and is removed from all events. This is like adding an array of event listener
s with EventTarget#on that calls EventTarget#off on all events the first time it is triggered.
Name | Type | Description |
---|---|---|
type | string | | An event name or an array of event names. |
fn | function | The function to be called once for each event name. |
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(type, fnopt)
Removes an event listener
for a specific event from an instance of EventTarget
. This makes it so that the event listener
will no longer get called when the named event happens.
Name | Type | Attributes | Description |
---|---|---|---|
type | string | | An event name or an array of event names. | |
fn | function | <optional> | The function to remove. If not specified, all listeners managed by Video.js will be removed. |
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(type, fn)
Adds an event listener
to an instance of an EventTarget
. An event listener
is a function that will get called when an event with a certain name gets triggered.
Name | Type | Description |
---|---|---|
type | string | | An event name or an array of event names. |
fn | function | The function to call with |
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(type, fn)
This function will add an event listener
that gets triggered only once. After the first trigger it will get removed. This is like adding an event listener
with EventTarget#on that calls EventTarget#off on itself.
Name | Type | Description |
---|---|---|
type | string | | An event name or an array of event names. |
fn | function | The function to be called once for each event name. |
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
(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) 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) 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) 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
Events
dispose
Signals that a advanced plugin is about to be disposed.