## Plugin

Parent class for all advanced plugins.

## Constructor

#### new Plugin(player)
`plugin.js`, `line 189`

  Creates an instance of this class.

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

  ##### Parameters:

  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:

  - Player#event:dispose

  ##### Throws:

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

  Type
    Error
  Mixes In:
    - module:evented~EventedMixin
    - module:stateful~StatefulMixin

### Members

#### static BASE_PLUGIN_NAME :string
`plugin.js`, `line 443`

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

#### state :Object
`mixins/stateful.js`, `line 22`

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

  Mixes In:
    - module:stateful~StatefulMixin.state

### Methods

#### static deregisterPlugin(name)
`plugin.js`, `line 372`

  De-register a Video.js plugin.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | The name of the plugin to be deregistered.

#### static getPlugin(name) → {function|undefined}
`plugin.js`, `line 424`

  Gets a plugin by name if it exists.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | The name of a plugin.

  ##### Returns:

  function | undefined -

  The plugin (or `undefined`).

#### static getPlugins(namesopt) → {Object|undefined}
`plugin.js`, `line 393`

  Gets an object containing multiple Video.js plugins.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `names` | Array | <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`, `line 417`

  Gets a plugin's version, if available

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | The name of a plugin.

  ##### Returns:

  string -

  The plugin's version or an empty string.

#### static isBasic(plugin) → {boolean}
`plugin.js`, `line 315`

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `plugin` | string | 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`, `line 336`

  Register a Video.js plugin.

  ##### Parameters:

  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 `Player` prototype.
  `plugin` | function | 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.

#### dispose()
`plugin.js`, `line 281`

  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:

  - Plugin#event:dispose

#### getEventHash(hashopt) → {Plugin~PluginEventHash}
`plugin.js`, `line 234`

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

  This returns that object or mutates an existing hash.

  ##### Parameters:

  Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | ---
  `hash` | Object | <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`, `line 271`

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` | Event | An event object provided by a "statechanged" event. ###### Properties
  Name | Type | Description
  --- | --- | ---
  `changes` | Object | An object describing changes that occurred with the "statechanged" event.

#### off(targetOrTypeopt, typeOrListeneropt, listeneropt)
`mixins/evented.js`, `line 286`

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

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `targetOrType` | string | 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_.
  `typeOrListener` | string | 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).
  `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:
    - module:evented~EventedMixin.off

#### on(targetOrType, typeOrListener, listeneropt)
`mixins/evented.js`, `line 194`

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

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `targetOrType` | string | 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.
  `typeOrListener` | string | 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).
  `listener` | function | <optional> | If the first argument was another evented object, this will be the listener function.

  Mixes In:
    - module:evented~EventedMixin.on

#### one(targetOrType, typeOrListener, listeneropt)
`mixins/evented.js`, `line 246`

  Add a listener to an event (or events) on this object or another evented object. The listener will only be called once and then removed.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `targetOrType` | string | 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.
  `typeOrListener` | string | 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).
  `listener` | function | <optional> | If the first argument was another evented object, this will be the listener function.

  Mixes In:
    - module:evented~EventedMixin.one

#### setState(stateUpdates) → {Object|undefined}
`mixins/stateful.js`, `line 37`

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `stateUpdates` | Object | 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:

  - module:stateful~StatefulMixin#event:statechanged

  ##### Returns:

  Object | undefined -

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

  Mixes In:
    - module:stateful~StatefulMixin.setState

#### trigger(event, hashopt) → {boolean}
`plugin.js`, `line 255`

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

  ##### Parameters:

  Name | Type | Attributes | Default | Description
  --- | --- | --- | --- | ---
  `event` | string | Object |  |  | An event type or an object with a type property.
  `hash` | Object | <optional> | {} | Additional data hash to merge with a PluginEventHash.

  ##### Returns:

  boolean -

  Whether or not default was prevented.

#### trigger(event, hashopt) → {boolean}
`mixins/evented.js`, `line 331`

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

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `event` | string | Object |  | An event type or an object with a type property.
  `hash` | Object | <optional> | An additional object to pass along to listeners.

  ##### Returns:

  boolean -

  Whether or not the default behavior was prevented.

  Mixes In:
    - module:evented~EventedMixin.trigger

### Type Definitions

#### PluginEventHash
`plugin.js`, `line 497`

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `instance` | string | For basic plugins, the return value of the plugin function. For advanced plugins, the plugin instance on which the event is fired.
  `name` | string | The name of the plugin.
  `plugin` | string | For basic plugins, the plugin function. For advanced plugins, the plugin class/constructor.

### Events

#### dispose
`plugin.js`, `line 284`

  Signals that a advanced plugin is about to be disposed.

  ##### Type:

  - EventTarget~Event