Skip to content
Cristian Bara edited this page Jul 9, 2013 · 28 revisions

Plugins extend functionalities of the player and/or can emit events on annotations or the player. Note: For simplicity, this documentation describes how to write a plugin in CoffeeScript. CopyAndPaste code examples into the "Try CoffeeScript" tool on the CoffeeScript documentation page if you aren't familiar with the syntax yet.

A Plugin can

  • subscribe to events coming from the player
  • subscribe to events coming from other plugins
  • ask for a widget space in one of the widget containers using the @player.allocateWidgetSpace(options) method.
  • emit events on annotations or on the player.
  • control playback (play, pause, seek, query for player position, etc.)

Plugin options

  • preferredContainer: define the widget container the plugin should create the widgets in.

How to code a new plugin

  1. Create a file for your plugin MyPlugin e.g. myplugin.coffee.
  2. Make sure it's compiled (see here how) and loaded on the page before instantiating the player
  3. Configure the player to load the plugin. plugins: MyPlugin: {}

Plugin Skeleton

Put following code into your plugin and it will be a plugin already.

class window.MyPlugin extends window.LimePlugin
  # Initialize the plugin
  init: ->
    # Initialize
    console.info @lime.annotations, "The optional color of MyPlugin is", @options.testOption
    for annotation in @lime.annotations

      # Create event listeners on all annotations
      annotation.bind 'becomeActive', =>
        console.info annotation, "just became active"

      annotation.bind 'becomeInactive', =>
        console.info annotation, "just became inactive"

  # Define default options
  defaults:
    testOption: 'blue'

Common instance variables

  • @lime: Lime player instance (see detailed API description here about what you can do with it).
  • @options: Hash of the plugin options. The default options should define a generic setting for the plugin which can be overridden for a specific case.

Available Plugins

  • LDPlugin (internal)
  • [DBPedia Info Plugin (old)](DBPedia Info plugin) (for demoing a simple plugin)
  • [DBPedia Info Plugin (new)](DBPedia Info plugin new) (for demoing a simple plugin)
  • [Map Plugin](Map plugin)
  • [Booking Plugin](Booking plugin)
  • [TV Plugin](TV Plugin)
  • [DBPedia Info for TV Plugin](DBPedia Info for TV plugin)
  • [Map for TV Plugin](Map for TV plugin)
  • [Help](Help Plugin) (interlal)
  • [User settings](User Settings)
  • [LSI Video Plugin](LSI Video Plugin)
  • [YouTube Plugin](Youtube plugin)
  • AnnotationOverlays Plugin (internal)
  • [Test Plugin](Test Plugin) (for testing purposes)

How to document a plugin

Documenting a Plugin means to describe the following features

  • Added features in common terms
  • Dependencies list of plugins and circumstances it needs to do its job correctly
  • Widgets it provides
  • Events on the Annotations or on the Lime player, that can be used by other plugins
  • Target environment/platform User interaction is largely independent of the plugin, and is set by the player based on the client and the interaction devices used with it. If a plugin has certain interaction restrictions these need to be noted.

There are three important aspects to every plugin:

  • The input values
  • The content queries
  • The layout choices