AMP - Plugin Adapter

Document created by Andrea Zuniga Employee on Jan 24, 2017Last modified by Andrea Zuniga Employee on Jan 26, 2017
Version 5Show Document
  • View in full screen mode

Maintainer: Andrea Zuniga  Maverick Chacon Garro

This document is part of Adaptive Media Player Web User Guide

 

 

The plugin adapter allows us to create custom plugins without modifying the core of the AMP player. The development of plugins can be done for the AMP integration team or customers developers, in the follow document it's describe the basic steps to work with the plugin adapter and best practices

 

Configuration

On the side of AMP configuration, you must add the plugin in the follow way:

Configuration

plugins:{

   NAME_OF_PLUGIN:{

      resources:[{

         src:"YOUR_ROUTE/amp.PLUGIN_NAME.js",

         type:"text/javascript"  

      }],

         data:{} // use it if you need another sources to load, id's etcetera

   }

}

 

After setup your configuration, you need to create the plugin with the same name as was setup before, on your code you need to add the follow:

 

amp.PLUGIN_NAME.js

function createPluginNamePlugin (player, config){

}

 

/**
* Registers a plugin factory function. This function is
* called when akamai.amp.AMP.create is called and the
* config object contains the plugin's key.
*
* @param {String} key
* The plugin's key. Used to configure the plugin.
*
* @param {Function} factory
* The factory function used to create plugin.
*
* @param {String|Array.<String>} [mode=["html", "flash"]]
* Optional player mode(s) in which the plugin can be used.
*/
akamai.amp.AMP.registerPlugin("PLUGIN_NAME", createPluginNamePlugin);

 

A good practice is also to ensure the akamai player or instance is ready before loading the plugin, you can add on your custom plugin as: if (window.akamai ){}

 

 

 

This document is part of Adaptive Media Player Web User Guide

2 people found this helpful

Attachments

    Outcomes