videojs/video.js · error · Error

Illegal plugin name, "${name}", cannot share a name with an

Error message

Illegal plugin name, "${name}", cannot share a name with an existing player method!

What it means

registerPlugin adds the plugin as a method on Player.prototype, so its name must not collide with an existing Player.prototype own property. A collision would shadow a core player method (e.g. 'play', 'src') and silently break playback, so registration refuses. Note: a duplicate plugin name only warns; this throw is specifically for Player method collisions.

Source

Thrown at src/js/plugin.js:354

   *          must not match an existing plugin or a method on the `Player`
   *          prototype.
   *
   * @param   {typeof Plugin|Function} plugin
   *          A sub-class of `Plugin` or a function for basic plugins.
   *
   * @return {typeof Plugin|Function}
   *          For advanced plugins, a factory function for that plugin. For
   *          basic plugins, a wrapper function that initializes the plugin.
   */
  static registerPlugin(name, plugin) {
    if (typeof name !== 'string') {
      throw new Error(`Illegal plugin name, "${name}", must be a string, was ${typeof name}.`);
    }

    if (pluginExists(name)) {
      log.warn(`A plugin named "${name}" already exists. You may want to avoid re-registering plugins!`);
    } else if (Player.prototype.hasOwnProperty(name)) {
      throw new Error(`Illegal plugin name, "${name}", cannot share a name with an existing player method!`);
    }

    if (typeof plugin !== 'function') {
      throw new Error(`Illegal plugin for "${name}", must be a function, was ${typeof plugin}.`);
    }

    pluginStorage[name] = plugin;

    // Add a player prototype method for all sub-classed plugins (but not for
    // the base Plugin class).
    if (name !== BASE_PLUGIN_NAME) {
      if (Plugin.isBasic(plugin)) {
        Player.prototype[name] = createBasicPlugin(name, plugin);
      } else {
        Player.prototype[name] = createPluginFactory(name, plugin);
      }
    }

View on GitHub (pinned to c3a7e0e6d2)

Solutions

  1. Choose a name that does not match a Player.prototype method (e.g. 'myPlay' instead of 'play').
  2. Check before registering: if (videojs.Player.prototype.hasOwnProperty(name)) throw.
  3. Namespace plugin names with a prefix to avoid collisions.

Example fix

// before
videojs.registerPlugin('src', myPlugin); // collides
// after
videojs.registerPlugin('mySrc', myPlugin);
Defensive patterns

Strategy: validation

Validate before calling

function safeRegisterPlugin(name, plugin) {
  if (videojs.Player.prototype.hasOwnProperty(name)) {
    throw new Error(`'${name}' collides with a Player method`);
  }
  return videojs.registerPlugin(name, plugin);
}

Type guard

const collidesWithPlayerMethod = (name) =>
  videojs.Player.prototype.hasOwnProperty(name);

Prevention

When it happens

Trigger: Calling videojs.registerPlugin('play', fn), registerPlugin('src', fn), or any name matching an own property on Player.prototype (src, load, pause, currentSrc, etc.).

Common situations: Generic plugin names like 'play', 'load', 'volume', 'src'; auto-generating plugin names from feature data without checking against Player API; renaming a plugin to a reserved name.

Related errors


AI-assisted analysis of videojs/video.js@c3a7e0e6d2 (2026-08-13). Data as JSON: /api/errors/11ff046ee6f72f9c. Report an issue: GitHub.