Subject says it all. The module should support JW Player plugins in a fairly generic and flexible manner.

Comments

rickvug’s picture

I've spoken with colleagues about this functionality. Notes from the conversation are below:

The JW Player module is meant to be a "generic" module that can be used as the base for any JW Player implementation. As such it would not be appropriate to implement specific plugins such as GA Pro and not others. Instead the JW Player module should provide a flexible API that allows other modules to register JW plugins on their own. At this point we could potentially register popular plugins from with the module itself by implementing the modules own API, but it would be just as simple to implement the relevant hook(s) from a module such as jw_player_ga_pro.

Specifically we spoke about a hook such as hook_jw_player_plugin_info() (or alternately hook_jw_player_plugin_register() or just hook_jw_player_plugin()). This hook would allow any module to register a plugin and all of its available configuration options with JW Player. The array format would be something like this:

$plugins['ga_pro2'] = array(
	'name' => 'Google Analytics Pro',
	'description' => t('A description of the plugin'),
	'config_options' => array(
		'trackstarts' = array(
			'name' => t('Track when videos start playing'),
			'allowed_values' = array('true, false'),
		)
		'key2' = array(
			'name' => "Human readable version of this configuration option",
			'allowed_values' = array('mode1', 'mode2', 'mode3', 'mode4'),
		)
	)
);

The human readable text for the plugin and configuration would be made available from within the presets form. This could be accomplished by calling something like jw_player_plugins_load(), which would fire the hook implementations and return all registered plugins. From this information the preset configuration form could be created. Which plugins are enabled and the settings for each plugin would be saved as part of a preset.

When rendering the player itself the configuration would be added to the JW player configuration as follows:

'plugins': {
   'gapro-2': {
       'trackstarts': 'true',
       'key2': 'mode4',
       'tracktime': 'false'
   }
   'another-plugin': {
       'foo': 'true',
       'bar': 'baz',
   }
}

While we have a fairly good idea of what needs to be accomplished many questions remain:

  • The JW Player module for Drupal 6 used XML based configuration. Was there a specific reason for this? Is this is a standard format? It is worth investigating to see what is the best approach. Nested PHP arrays are naturally "Drupally" but we also want to follow any JW Player standards that exist.
  • How should local plugins not hosted with Longtail video be loaded, if at all?
  • How do we handle JW Player account ids and access to specific plugins covered by one's license?
  • Some plugins such as the HD player require a configuration values that are unique for every video, meaning that they can not be configured via the preset. Do we provide a callback for preset values, handle this via pre-process or solve in some other fashion?
girishmuraly’s picture

StatusFileSize
new6.1 KB

Attaching patch based on similar outline @rickvug set

With this patch, modules can implement hook_jw_player_plugin_info() and hook_jw_player_plugin_info_alter() to register and alter preset-plugins respectively.

The plugins should be registered in this format:

function hook_jw_player_plugin_info($preset) {
  // Create a plugin keyed by its actual plugin id
  $plugins['foo'] = array(
    'name' => t('Foobar'),
    'description' => t('A plugin to do foobar'),
    // Note: Each option should be in a valid FAPI format, as it is directly referenced in the preset settings form,
    // except the '#title' may be omitted for the name of the option to be taken as default
    'config options' => array(
      'accountid' => array(
        '#type' => 'textfield',
        '#required' => TRUE,
        '#size' => 15,
        '#default_value' => 'bar'
      ),
      'param2' => array(
        '#type' => 'select',
        '#options' => array('TRUE' => 'TRUE', 'FALSE' => 'FALSE'),
        '#default_value' => 'TRUE',
        '#description' => t('Enables the controls on an item when playing')),
    ),
  );
  return $plugins;
}

Also created a GA Pro2 plugin at http://drupal.org/sandbox/girishmuraly/1344992.

rickvug’s picture

Status: Active » Fixed

@Girish The code looks good. Committed! Let's continue to monitor the architecture for plugins as additional use cases come up. At the moment reworking #1318342: Add support for Closed captions and Audio Descriptions to use this new plugin API would be an excellent test case.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

remy40’s picture

StatusFileSize
new584 bytes

Hi,

I'm currently working on a drupal module to support JW Player captions plugin, using your plugin interfaces.

Some plugins need to update their config dynamically using some field data, or anything else, so I have added a call to a "plugin config update" function in jw_player_preprocess(). I don't know if it's the best method.

Here is the patch.