new Plugin(player)

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 188](https://docs.videojs.com/plugin.js.html#line188)

Creates an instance of this class.

Sub-classes should call super to ensure plugins are properly initialized.

Parameters:
NameTypeDescription
playerPlayer

A Video.js player instance.

Fires:
Listens to Events:
Throws:

If attempting to instantiate the base Plugin class directly instead of via a sub-class.

  • Type

    Error

Mixes In:

Members

static BASE_PLUGIN_NAME :string

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 457](https://docs.videojs.com/plugin.js.html#line457)

The name of the base plugin class as it is registered.

state :Object

[mixins/stateful.js](https://docs.videojs.com/mixins_stateful.js.html), [line 22](https://docs.videojs.com/mixins_stateful.js.html#line22)

A hash containing arbitrary keys and values representing the state of the object.

state :Object

[mixins/stateful.js](https://docs.videojs.com/mixins_stateful.js.html), [line 22](https://docs.videojs.com/mixins_stateful.js.html#line22)

A hash containing arbitrary keys and values representing the state of the object.

Methods

static deregisterPlugin(name)

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 386](https://docs.videojs.com/plugin.js.html#line386)

De-register a Video.js plugin.

Parameters:
NameTypeDescription
namestring

The name of the plugin to be de-registered. Must be a string that matches an existing plugin.

Throws:
  • If an attempt is made to de-register the base plugin.

    • Type

      Error

static getPlugin(name) → {function|undefined}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 438](https://docs.videojs.com/plugin.js.html#line438)

Gets a plugin by name if it exists.

Parameters:
NameTypeDescription
namestring

The name of a plugin.

Returns:

function | undefined -

The plugin (or undefined).

static getPlugins(namesopt) → {Object|undefined}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 407](https://docs.videojs.com/plugin.js.html#line407)

Gets an object containing multiple Video.js plugins.

Parameters:
NameTypeAttributesDescription
namesArray<optional>

If provided, should be an array of plugin names. Defaults to all plugin names.

Returns:

Object | undefined -

An object containing plugin(s) associated with their name(s) or undefined if no matching plugins exist).

static getPluginVersion(name) → {string}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 431](https://docs.videojs.com/plugin.js.html#line431)

Gets a plugin’s version, if available

Parameters:
NameTypeDescription
namestring

The name of a plugin.

Returns:

string -

The plugin’s version or an empty string.

static isBasic(plugin) → {boolean}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 325](https://docs.videojs.com/plugin.js.html#line325)

Determines if a plugin is a basic plugin (i.e. not a sub-class of Plugin).

Parameters:
NameTypeDescription
pluginstring | function

If a string, matches the name of a plugin. If a function, will be tested directly.

Returns:

boolean -

Whether or not a plugin is a basic plugin.

static registerPlugin(name, plugin) → {function}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 346](https://docs.videojs.com/plugin.js.html#line346)

Register a Video.js plugin.

Parameters:
NameTypeDescription
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 Player prototype.

pluginfunction

A sub-class of Plugin or a function for basic plugins.

Returns:

function -

For advanced plugins, a factory function for that plugin. For basic plugins, a wrapper function that initializes the plugin.

any(targetOrType, typeOrListener, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 357](https://docs.videojs.com/mixins_evented.js.html#line357)

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.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 357](https://docs.videojs.com/mixins_evented.js.html#line357)

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.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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()

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 291](https://docs.videojs.com/plugin.js.html#line291)

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(hashopt) → {Plugin~PluginEventHash}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 244](https://docs.videojs.com/plugin.js.html#line244)

Each event triggered by plugins includes a hash of additional data with conventional properties.

This returns that object or mutates an existing hash.

Parameters:
NameTypeAttributesDefaultDescription
hashObject<optional>
{}

An object to be used as event an event hash.

Returns:

Plugin~PluginEventHash -

An event hash object with provided properties mixed-in.

abstract handleStateChanged(e)

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 281](https://docs.videojs.com/plugin.js.html#line281)

Handles “statechanged” events on the plugin. No-op by default, override by subclassing.

Parameters:
NameTypeDescription
eEvent

An event object provided by a “statechanged” event.

Properties
NameTypeDescription
changesObject

An object describing changes that occurred with the “statechanged” event.

off(targetOrTypeopt, typeOrListeneropt, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 397](https://docs.videojs.com/mixins_evented.js.html#line397)

Removes listener(s) from event(s) on an evented object.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object<optional>

If this is a string or array, it represents the event type(s).

  1. Another evented object can be passed here instead, in which case
  2. 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(targetOrTypeopt, typeOrListeneropt, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 397](https://docs.videojs.com/mixins_evented.js.html#line397)

Removes listener(s) from event(s) on an evented object.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object<optional>

If this is a string or array, it represents the event type(s).

  1. Another evented object can be passed here instead, in which case
  2. 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, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 256](https://docs.videojs.com/mixins_evented.js.html#line256)

Add a listener to an event (or events) on this object or another evented object.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 256](https://docs.videojs.com/mixins_evented.js.html#line256)

Add a listener to an event (or events) on this object or another evented object.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 308](https://docs.videojs.com/mixins_evented.js.html#line308)

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.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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, listeneropt)

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 308](https://docs.videojs.com/mixins_evented.js.html#line308)

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.

Parameters:
NameTypeAttributesDescription
targetOrTypestring | Array | Element | Object

If this is a string or array, it represents the event type(s) that will trigger the listener.

  1. Another evented object can be passed here instead, which will
  2. cause the listener to listen for events on that object.
  3. In either case, the listeners this value will be bound to
  4. 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}

[mixins/stateful.js](https://docs.videojs.com/mixins_stateful.js.html), [line 37](https://docs.videojs.com/mixins_stateful.js.html#line37)

Set the state of an object by mutating its state object in place.

Parameters:
NameTypeDescription
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:

Object | undefined -

An object containing changes that occurred. If no changes occurred, returns undefined.

setState(stateUpdates) → {Object|undefined}

[mixins/stateful.js](https://docs.videojs.com/mixins_stateful.js.html), [line 37](https://docs.videojs.com/mixins_stateful.js.html#line37)

Set the state of an object by mutating its state object in place.

Parameters:
NameTypeDescription
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:

Object | undefined -

An object containing changes that occurred. If no changes occurred, returns undefined.

trigger(event, hashopt) → {boolean}

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 265](https://docs.videojs.com/plugin.js.html#line265)

Triggers an event on the plugin object and overrides EventedMixin.trigger.

Parameters:
NameTypeAttributesDefaultDescription
eventstring | Object

An event type or an object with a type property.

hashObject<optional>
{}

Additional data hash to merge with a PluginEventHash.

Returns:

boolean -

Whether or not default was prevented.

trigger(event, hashopt) → {boolean}

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 442](https://docs.videojs.com/mixins_evented.js.html#line442)

Fire an event on this evented object, causing its listeners to be called.

Parameters:
NameTypeAttributesDescription
eventstring | Object

An event type or an object with a type property.

hashObject<optional>

An additional object to pass along to listeners.

Returns:

boolean -

Whether or not the default behavior was prevented.

trigger(event, hashopt) → {boolean}

[mixins/evented.js](https://docs.videojs.com/mixins_evented.js.html), [line 442](https://docs.videojs.com/mixins_evented.js.html#line442)

Fire an event on this evented object, causing its listeners to be called.

Parameters:
NameTypeAttributesDescription
eventstring | Object

An event type or an object with a type property.

hashObject<optional>

An additional object to pass along to listeners.

Returns:

boolean -

Whether or not the default behavior was prevented.

version()

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 228](https://docs.videojs.com/plugin.js.html#line228)

Get the version of the plugin that was set on .VERSION

Type Definitions

PluginEventHash

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 511](https://docs.videojs.com/plugin.js.html#line511)

Properties:
NameTypeDescription
instancestring

For basic plugins, the return value of the plugin function. For advanced plugins, the plugin instance on which the event is fired.

namestring

The name of the plugin.

pluginstring

For basic plugins, the plugin function. For advanced plugins, the plugin class/constructor.

Events

dispose

[plugin.js](https://docs.videojs.com/plugin.js.html), [line 294](https://docs.videojs.com/plugin.js.html#line294)

Signals that a advanced plugin is about to be disposed.

Type: